| plotSpectra | R Documentation |
plotSpectra() plots either a number density or a biomass density, either
with respect to size or with respect to logarithmic size. Those two choices
are made with the biomass and per_log_size arguments. When called with a
MizerSim object, the abundance is averaged over the specified time range
(a single value for the time range can be used to plot a single time step).
When called with a MizerParams object the initial abundance is plotted.
With size_axis = "l", densities are converted from per unit weight to per
unit length; densities with respect to logarithmic size are instead
converted between logarithmic weight and logarithmic length intervals.
plotSpectra(
object,
species = NULL,
wlim = c(NA, NA),
llim = c(NA, NA),
ylim = c(NA, NA),
power = NULL,
biomass = NULL,
per_log_size = NULL,
total = FALSE,
resource = TRUE,
background = TRUE,
highlight = NULL,
log_x = TRUE,
log_y = TRUE,
log = NULL,
size_axis = c("w", "l"),
return_data = FALSE,
...
)
The plotted quantity is the number density multiplied by w^power, where
the power is the sum of the two choices above: a biomass density carries one
factor of the weight and a density with respect to logarithmic size carries
another:
per_log_size = FALSE | per_log_size = TRUE |
|
biomass = FALSE | power = 0 | power = 1 |
biomass = TRUE | power = 1 | power = 2 |
The power argument can still be given instead, and is the only way to ask
for a power that is not the sum of the two flags. But note that power on
its own does not distinguish the two entries with power = 1: it is taken
to mean the biomass density with respect to weight, which is what determines
the y-axis label and the Jacobian used for a length axis. Supplying power
together with a flag that contradicts it is an error.
The log_x argument only controls how the size axis is displayed; it does
not change the density on the y-axis. In particular, showing weight on a
logarithmic axis does not by itself convert a density per unit weight into a
density per logarithmic weight interval. That choice is made with
per_log_size, and the conversion from weight to length then uses the
logarithmic Jacobian, irrespective of the value of log_x.
plotlySpectra() is the interactive plotly version. To compare spectra from
two objects use plotSpectra2(). To show relative differences use
plotSpectraRelative().
A ggplot2 object, unless return_data = TRUE, in which case a data
frame with the four variables 'w' (or 'l' if size_axis = "l"), 'value',
'Species', 'Legend' is returned. plotlySpectra() returns a plotly object.
plotting_functions
Other plotting functions:
addPlot(),
animate(),
plot,
plot2(),
plotBiomass(),
plotCDF(),
plotCDF2(),
plotDiet(),
plotFMort(),
plotFeedingLevel(),
plotGrowthCurves(),
plotMizerParams,
plotMizerSim,
plotPredMort(),
plotRelative(),
plotSpectra2(),
plotSpectraRelative(),
plotYield(),
plotYieldGear(),
plotYieldVsF(),
plotting_functions
params <- NS_params
sim <- project(params, effort=1, t_max=20, t_save = 2, progress_bar = FALSE)
plotSpectra(sim)
plotSpectra(sim, wlim = c(1e-6, NA))
plotSpectra(sim, time_range = 10:20)
plotSpectra(sim, time_range = 10:20, biomass = FALSE)
plotSpectra(sim, species = c("Cod", "Herring"), per_log_size = TRUE)
plotSpectra(sim, species = c("Cod", "Herring"), size_axis = "l")
# Returning the data frame
fr <- plotSpectra(sim, return_data = TRUE)
str(fr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.