Learn R Programming

mizer (version 3.0.0)

plot: Plot mizer arrays

Description

Many mizer functions return values that depend on species and either size or time. plot() creates a ggplot2 figure with one line for each species showing the values against size or against time (depending on the type of output). plotHover() creates an interactive version of the same figure.

Value

A ggplot2 object, unless return_data = TRUE, in which case a data frame is returned. plotHover() returns a plotly object.

Arguments

x

An ArraySpeciesBySize, ArrayTimeBySpecies, or ArrayTimeBySpeciesBySize object.

...

Arguments used by all methods:

species

Character vector of species to include. NULL (default) means all species.

highlight

Name or vector of names of the species to be highlighted.

total

A boolean value that determines whether the total over all selected species is plotted as well. Default is FALSE.

background

A boolean value that determines whether background species are included. Ignored if the model does not contain background species. Default is TRUE.

return_data

If TRUE, return the data frame instead of the plot.

log_x

If TRUE, use a log10 x-axis. Default is TRUE for size spectra and FALSE for time series.

log_y

If TRUE, use a log10 y-axis. Default is FALSE for ArraySpeciesBySize and TRUE for ArrayTimeBySpecies.

log

Character string specifying which axes should use log10 scales, in the same form as the base plot() argument. For example, "x", "y", "xy" or "". If supplied, this overrides log_x and log_y.

ylim

A numeric vector of length two providing lower and upper limits for the value (y) axis. Use NA to refer to the existing minimum or maximum.

y_ticks

The approximate number of ticks desired on the y axis.

For ArraySpeciesBySize and ArrayTimeBySpeciesBySize methods:

all.sizes

If FALSE (default), values outside a species' size range (w_min to w_max) are removed.

wlim

A numeric vector of length two providing lower and upper limits for the weight (x) axis. Use NA to refer to the existing minimum or maximum.

llim

A numeric vector of length two providing lower and upper limits for the length (x) axis when size_axis = "l". Use NA to refer to the existing minimum or maximum.

size_axis

Whether to plot size as weight ("w", default) or length ("l"), using the allometric weight-length relationship.

For ArrayTimeBySpecies methods:

tlim

A numeric vector of length two providing lower and upper limits for the time axis, e.g. c(1980, 2000). Use NA to apply no limit at that end. Default is c(NA, NA).

For ArrayTimeBySpeciesBySize methods:

time

The time to display. Default (NULL) is the final time step.

Details

This works because the mizer functions that give values that depend on species and size return an ArraySpeciesBySize object and those that give values that depend on species and time return an ArrayTimeBySpecies object. These objects have attributes that store the name of the value, its units, and a reference to the MizerParams object that the value was computed from. This allows the plots to be automatically labelled and coloured appropriately.

To compare two mizer arrays in a single plot, use plot2(). To show the relative difference between two arrays, use plotRelative().

See Also

Other plotting functions: addPlot(), animate.ArrayTimeBySpeciesBySize(), plot2(), plotBiomass(), plotCDF(), plotCDF2(), plotDiet(), plotFMort(), plotFeedingLevel(), plotGrowthCurves(), plotMizerParams, plotMizerSim, plotPredMort(), plotRelative(), plotSpectra(), plotSpectra2(), plotSpectraRelative(), plotYield(), plotYieldGear(), plotting_functions

Examples

Run this code
# \donttest{
plot(getEncounter(NS_params))
plot(getFeedingLevel(NS_params), species = c("Cod", "Herring"))
plot(getPredMort(NS_params), species = c("Cod", "Herring"),
     size_axis = "l")
# }
# \donttest{
plot(getBiomass(NS_sim))
plot(getBiomass(NS_sim), species = c("Cod", "Herring"), total = TRUE)
plot(getYield(NS_sim), species = c("Cod", "Herring"))
# }
# \donttest{
plot(getFMort(NS_sim), time = 2010)
# }

Run the code above in your browser using DataLab