Plot Kernel Density Using River Distance

Description

Produces a kernel density plot from a kernel density object created by makeriverdensity.

If the kernel density object includes densities from multiple surveys, a new plot will be created for each survey.

Densities can be displayed using either line widths, color, or both.

The relative densities that are displayed in the plot are calculated according to the form (density/maxdensity)^pwr, with the value of pwr set by the pwr argument. Setting pwr to a value less than 1 allows smaller values to be more visible on the plot.

Usage

1
2
3
4
5
6
## S3 method for class 'riverdensity'
plot(x, whichplots = NULL, points = TRUE,
  bycol = TRUE, bylwd = TRUE, maxlwd = 10, pwr = 0.7, scalebyN = TRUE,
  ramp = "grey", lwd = 1, linecol = "black", denscol = "black",
  alpha = 1, dark = 1, showN = TRUE, main = NULL, xlab = "",
  ylab = "", add = FALSE, ...)

Arguments

x

A river density object created by makeriverdensity.

whichplots

A vector of plots to produce, if multiple plots are produced. For example, specifying whichplot=c(2,3,4) will result in only the second, third, and fourth plots of the sequence being produced. Accepting the default (NULL) will result in all plots being produced.

points

Whether to add the points used for density calculation. Defaults to TRUE.

bycol

Whether to use a color ramp to show densities. Defaults to TRUE.

bylwd

Whether to use line thickness to show densities. Defaults to TRUE.

maxlwd

The maximum line width to use if bylwd is set to TRUE. Defaults to 10.

pwr

The power to use in the nonlinear transformation calculating the relative density values to be displayed (see above.) Defaults to 0.7.

scalebyN

Whether to display relative density values scaled by sample size. Specifying scalebyN=TRUE will show larger density values associated with surveys with more points, and may be more appropriate for displaying total density. Specifying scalebyN=FALSE will allow surveys with smaller sample sizes to be plotted with similar density values as those with larger sample sizes, and may be more appropriate for displaying relative density. Defaults to TRUE.

ramp

The color ramp used to display densities if bycol is set to TRUE. Allowed values are "grey" (or "gray"), "red", "green", "blue", "heat", "stoplight", and "rainbow". Defaults to "grey".

lwd

The line width to use for background lines if bylwd is set to TRUE, or all lines if bylwd is set to FALSE. Defaults to 1.

linecol

The line color to use for background lines if bylwd is set to TRUE. Defaults to "black".

denscol

The line color to use for showing density if bylwd is set to TRUE. Defaults to "black".

alpha

The opacity value for lines. This could potentially allow multiple density plots to be overlayed with different colors.

dark

A color-saturation adjustment, with values in [0,1]. A value of 1 uses the true colors, and a value less than 1 will render the colors as slightly darker (less saturated), which may be appear better. Defaults to 1.

showN

Whether to automatically include the number of points used as part of the plot title(s).

main

Plot title(s), either given as a single text string which is repeated if multiple plots are produced, or a vector of text strings (one for each plot produced). If multiple plots are produced (resulting from multiple surveys), accepting the default (NULL) will result in each unique value of survey being used as the plot title, along with the sample size if showN is set to TRUE.

xlab

X-axis label

ylab

Y-axis label

add

Whether to produce a new plot (FALSE), or add to an existing plot (TRUE). Defaults to FALSE.

...

Additional plotting parameters.

Author(s)

Matt Tyers

See Also

makeriverdensity, plotriverdensitypoints

Examples

1
2
3
4
5
6
7
data(Gulk, fakefish)

Gulk_dens <- makeriverdensity(seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, 
  survey=fakefish$flight.date)
  
# # 10 plots will be created, recommend calling par(mfrow=c(2,5))
plot(x=Gulk_dens)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.