Skip to contents

plotRelative() plots the difference between two compatible mizer array objects relative to their average. If the values in the first object are \(N_1\) and the values in the second are \(N_2\), it plots $$2 (N_2 - N_1) / (N_1 + N_2).$$

Usage

plotRelative(
  x,
  y,
  species = NULL,
  log_x,
  ylim = c(NA, NA),
  total = FALSE,
  background = TRUE,
  highlight = NULL,
  ...
)

Arguments

x

The first of two compatible mizer array objects to compare. Can be an ArraySpeciesBySize, ArrayTimeBySpecies, ArrayTimeBySpeciesBySize, ArrayResourceBySize or ArrayTimeByResourceBySize object.

y

The second mizer array object, compatible with x.

species

Character vector of species to include. NULL (default) means all species. A resource array holds a single spectrum, so this argument is not used by the resource methods, which warn if it is set.

log_x

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

ylim

A numeric vector of length two providing lower and upper limits for the value (y) axis.

total

A boolean value that determines whether the total is plotted as well. The total is the total of everything the array holds, every species and every size, whatever is drawn. Default is FALSE. Not used by the resource methods, which warn if it is set.

background

A boolean value that determines whether background species are included. Ignored if the model does not contain background species. Default is TRUE. Not used by the resource methods, which warn if it is set.

highlight

Name or vector of names of the species to be highlighted with a thicker line.

...

Further arguments used by only some of the methods:

For the ArraySpeciesBySize, ArrayTimeBySpeciesBySize, ArrayResourceBySize and ArrayTimeByResourceBySize methods:

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.

For the ArraySpeciesBySize and ArrayTimeBySpeciesBySize methods:

all.sizes

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

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 of each species, or of the resource, see resource_params().

per_log_size

For an array that holds a density, whether to express it per logarithmic size (TRUE) rather than per size (FALSE). The default, NULL, leaves the density as it stands. An error for an array that does not hold a density.

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 the ArrayTimeBySpeciesBySize and ArrayTimeByResourceBySize methods:

time

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

Value

A ggplot2 object.

Examples

# \donttest{
params <- NS_params
given_species_params(params)["Cod", "w_mat"] <- 1200
plotRelative(getEGrowth(NS_params), getEGrowth(params),
             wlim = c(500, 2000), log_x = FALSE, species = "Cod")


# The same works for the resource
params2 <- setResource(NS_params,
                       resource_capacity = 2 * resource_capacity(NS_params))
plotRelative(resource_capacity(NS_params), resource_capacity(params2))

# }