Skip to contents

This plots the change between the steady state spectra of two mizer objects. Let the spectra of the two objects be represented as \(N_1(w)\) and \(N_2(w)\). This function plots $$ \frac{N_2(w) - N_1(w)}{N_1(w)}$$ expressed as a percentage (multiplied by 100) when use_percent = TRUE (the default), or as the raw relative proportion when use_percent = FALSE.

Usage

plotSpectraChange(
  object1,
  object2,
  species = NULL,
  power = NULL,
  use_percent = TRUE,
  biomass = NULL,
  per_log_size = NULL,
  return_data = FALSE,
  ...
)

plotlySpectraChange(object1, object2, ...)

Arguments

object1

An object of class MizerSim or MizerParams

object2

An object of class MizerSim or MizerParams

species

The species to be selected. Optional. By default all species are selected. A vector of species names, or a numeric vector with the species indices, or a logical vector indicating for each species whether it is to be selected (TRUE) or not.

power

The abundance is plotted as the number density times the weight raised to this power. power = 1 gives the biomass density, power = 2 the biomass density with respect to logarithmic size. Superseded by biomass and per_log_size, which mizer 3.3 introduced in its place; power still works and is still the only way to ask for a power that is not the sum of the two flags.

use_percent

Logical. If TRUE (default), the change is expressed as a percentage (e.g. 50 for a 50% increase). If FALSE, the raw relative proportion is plotted instead (e.g. 0.5).

biomass

Whether to plot the biomass density rather than the number density. Passed on to mizer::plotSpectra().

per_log_size

Whether to plot the density with respect to logarithmic size rather than with respect to size. Passed on to mizer::plotSpectra().

return_data

Logical. If TRUE, returns the data frame underlying the plot instead of the plot itself. Default FALSE.

...

Parameters passed to plotSpectra(), including size_axis, which switches both spectra and the plot onto a length axis.

Value

A ggplot2 object, or a data frame if return_data = TRUE.

Details

For the difference calculated relative to the average of the two spectra, \(2 (N_2(w) - N_1(w)) / (N_2(w) + N_1(w))\), use mizer's own mizer::plotSpectraRelative(), which already dispatches correctly for mizerReef objects.

The individual spectra are calculated by the mizer::plotSpectra() function which is passed all additional arguments you supply. So you can for example determine a size range over which to average the simulation results via the time_range argument. See mizer::plotSpectra() for more options.