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.
# S3 method for 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,
scalebar = TRUE,
...
)
A river density object created by makeriverdensity.
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.
Whether to add the points used for density calculation.
Defaults to TRUE
.
Whether to use a color ramp to show densities. Defaults to
TRUE
.
Whether to use line thickness to show densities. Defaults to
TRUE
.
The maximum line width to use if bylwd
is set to
TRUE
. Defaults to 10.
The power to use in the nonlinear transformation calculating the relative density values to be displayed (see above.) Defaults to 0.7.
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
.
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"
.
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.
The line color to use for background lines if bylwd
is
set to TRUE
. Defaults to "black"
.
The line color to use for showing density if bylwd
is
set to TRUE
. Defaults to "black"
.
The opacity value for lines. This could potentially allow multiple density plots to be overlayed with different colors.
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.
Whether to automatically include the number of points used as part of the plot title(s).
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
.
X-axis label
Y-axis label
Whether to produce a new plot (FALSE
), or add to an
existing plot (TRUE
). Defaults to FALSE
.
Whether to add a scale bar to plot(s). Defaults to TRUE
.
Additional plotting parameters.
Matt Tyers
makeriverdensity, plotriverdensitypoints
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)
Run the code above in your browser using DataLab