plot.osmose: Plot method for osmose objects

View source: R/osmose-class.R

plot.osmoseR Documentation

Plot method for osmose objects

Description

This method takes a osmose object and produce useful plots

This function implements a plot method for different osmose classes.

Usage

## S3 method for class 'osmose'
plot(x, what = "biomass", ...)

## S3 method for class 'osmose.biomass'
plot(
  x,
  ts = TRUE,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  initialYear = NULL,
  replicates = TRUE,
  freq = 12,
  horizontal = FALSE,
  conf = 0.95,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  alpha = NULL,
  border = NULL,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  legend = TRUE,
  units = "tonnes",
  zero = FALSE,
  ...
)

## S3 method for class 'osmose.abundance'
plot(
  x,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  initialYear = NULL,
  ts = TRUE,
  type = 1,
  replicates = TRUE,
  freq = 12,
  horizontal = FALSE,
  conf = 0.95,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  alpha = NULL,
  border = NULL,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  legend = TRUE,
  units = "individuals",
  ...
)

## S3 method for class 'osmose.yield'
plot(
  x,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  initialYear = NULL,
  ts = TRUE,
  type = 1,
  replicates = TRUE,
  freq = 12,
  horizontal = FALSE,
  conf = 0.95,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  alpha = NULL,
  border = NULL,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  legend = TRUE,
  units = "tonnes",
  ...
)

## S3 method for class 'osmose.yieldN'
plot(
  x,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  initialYear = NULL,
  ts = TRUE,
  type = 1,
  replicates = TRUE,
  freq = 12,
  horizontal = FALSE,
  conf = 0.95,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  alpha = NULL,
  border = NULL,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  legend = TRUE,
  units = "individuals",
  ...
)

## S3 method for class 'osmose.biomassByTL'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "", y = "tonnes"),
  ...
)

## S3 method for class 'osmose.biomassBySize'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "cm", y = "tonnes"),
  ...
)

## S3 method for class 'osmose.biomassByAge'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "years", y = "tonnes"),
  ...
)

## S3 method for class 'osmose.abundanceByTL'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "", y = "individuals"),
  ...
)

## S3 method for class 'osmose.abundanceBySize'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "cm", y = "individuals"),
  ...
)

## S3 method for class 'osmose.abundanceByAge'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "years", y = "individuals"),
  ...
)

## S3 method for class 'osmose.yieldNBySize'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "cm", y = "individuals"),
  ...
)

## S3 method for class 'osmose.yieldNByAge'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "years", y = "individuals"),
  ...
)

## S3 method for class 'osmose.yieldBySize'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "cm", y = "tonnes"),
  ...
)

## S3 method for class 'osmose.yieldByAge'
plot(
  x,
  type = 1,
  species = NULL,
  speciesNames = NULL,
  start = NULL,
  end = NULL,
  freq = 12,
  horizontal = FALSE,
  factor = 0.001,
  xlim = NULL,
  ylim = NULL,
  col = NULL,
  border = NULL,
  legend = TRUE,
  lty = 1,
  lwd = 1,
  axes = TRUE,
  units = list(x = "years", y = "tonnes"),
  ...
)

Arguments

x

osmose object.

what

Variable name to plot. By default is what = "biomass". See Details

...

Extra arguments of the function. See Details.

ts

logical parameter. By default ts = TRUE and the plots are going to be time series where the x-axis is the time. For plots where the x-axis is not the time ts = FALSE.

type

A numeric value, indicating the type of plot to be used (type = 1, by default). See Details.

species

A numeric vector specifying the species that will be showed. If NULL (default), all the available species time series will be plotted. See Details.

speciesNames

A vector with the names for each species. If NULL (default) the names of x will be used.

start

A numeric value indicating the first element of the time indexation of the object x is specified with this parameter. By default start = NULL and the time indexation start with the first element of x.

end

A numeric value. The last element of the time indexation of the object x is specified with this parameter. By default end = NULL and the time indexation finish with the last element of x.

initialYear

A numeric value. It specifies the first element that is going to be used on the x axis for the plots.

replicates

logical. It controls to show whether the values in each simulation (TRUE) or the median of the values along the time (FALSE).

freq

A numeric value to indicate the steps by year used in the time series. Default values, see Details.

horizontal

a logical value. If FALSE, plot types that do not represent time series (boxplots and barplots) will be drawn horizontally.

conf

numeric single value indicating the confidence interval showed in the plot as shadow. By default conf = 0.95.

factor

A number to indicate the scale of the variable on the y-axis. By default factor = 1e-3.

xlim, ylim

numeric vectors of length 2, giving the x and y coordinates ranges.

col

A vector with the color names for the plots. By default col = NULL and the colors will be chosen by the function.

alpha

factor modifying the opacity alpha given to confidence interval (CI) polygons (check adjustcolor). By default (NULL), its value will depend on the plot type. See Details.

border

the color to draw the border of CI polygons, bar plots and box plots. The default value (NULL) will depend on the type, see Details.

lty

The line type (check par).

lwd

The line width (check par).

axes

a logical value indicating whether both axes should be drawn on the plot.

legend

logical do you want to show a legend of species? (valid only for those plot types TS-2)

units

String with units of the variable that defines the label set on top of the plot. If NULL (default), the value will depend on the class, see Details.

Details

what argument can take next values:

  • "biomass" to plot the species biomass (see plot.osmose.biomass)

  • "abundance" to plot the species abundance (see plot.osmose.abundance)

  • "yield" to plot the species yield (see plot.osmose.yield)

  • "yieldN" to plot the species yield (in numbers) (see plot.osmose.yieldN)

User can select within different plot types depending on the osmose class. So, for classes biomass, abundance, yield and yieldN (Group 1) the user must use ts and type arguments to specify the type of plot to draw.

So, for the Group 1 and ts = TRUE, user will select within:

  • type = 1: Generates a matrix plot of the selected variable plotted independently.

  • type = 2: Generates a single plot with overlaped time series. You can include confidence interval shadow around lines.

  • type = 3: Generates a single plot with cumulated time series. So, the method will sort and overlap the time series values for the selected variable

  • type = 4: ONLY valid for a single species. It generates a bar plot of the time series.

For the Group 1 and ts = FALSE, user will select within:

  • type = 1: Generates a bar plot of the selected variable by species, including interval confidence bars.

  • type = 2: Generates a boxplot of the selected variable by species.

The Group 2 refers classes of Group 1 with By specification (e.g. yieldNBySize, abundanceByAge, biomassByTL). There are 2 available plot types:

  • type = 1: Generates a bar plot of the selected variable by species. The ... will be passed to the internal barplot function.

  • type = 2: Generates a plot using image.plot function, placing the species in the left axis, the By-variable (e.g. Size) on the bottom and the main variable (e.g. biomass) in a color scale. The ... will be passed to the internal image.plot function.

Both alpha and border controls the opacity and the color of border, respectively, for polygons, bar plots and box plots. So depending on the ts-type, they will have different default values:

  • alpha = 0.3 & border = NA for TS = TRUE with type = 1 or 2.

  • alpha = 1 & border = TRUE for Everything else.

species argument follows the indexation way of java: starting in zero, as osmose-java returns species outputs.

Default value for freq will be calculated from x: freq = 1/x$model$start.

units could be whether a single character vector (currently applied on classes without By, e.g. osmose.biomass, osmose.yieldN) or a list of length 2 specifying the units for x and y (currently used with classes with By, e.g. plot.osmose.biomassBySize, plot.osmose.yieldNByAge).

Extra arguments can be passed from plot.default using ...: cex, cex.axis, border (useful for polygon, boxplots and barplots), etc. It is important to notice that, depending on where the ellipsys is passed, it allows and refuse the use of certain arguments. For instance, if the selected plot is a bar plot, the ... will be passed to the internal barplot call, so if cex argument is used, it will create a conflict and an error (a typical error of using cex in barplot function).

Value

A graph of an osmose object.

Author(s)

Criscely Lujan Paredes


roliveros-ramos/osmose documentation built on Feb. 19, 2023, 8:19 a.m.