Package 'ggplotFL'

Title: Using ggplot2 in FLR
Description: Using ggplot2 for FLR. Provides (1) overloaded ggplot methods for various FLR classes, (2) ggplot-based versions of standard plots in the FLCore package, and (3) new geoms for using FLR objects.
Authors: Iago Mosqueira [cre, aut] , Laurence T. Kell [aut]
Maintainer: Iago Mosqueira <[email protected]>
License: GPL-2
Version: 2.7.0.9133
Built: 2024-11-03 04:21:37 UTC
Source: https://github.com/flr/ggplotFL

Help Index


cohcorrplot

Description

A correlation plot that show and quantifies correlation along cohorts. Typically used on catch or survey abundances-at-age.

Usage

cohcorrplot(x, ...)

## S4 method for signature 'FLQuant'
cohcorrplot(x, ...)

## S4 method for signature 'FLCohort'
cohcorrplot(x, diag_size = 16, lower_size = 6)

Arguments

x

An object with the abundance at age information. FLQuant or FLCohort.

...

Any extra arguments

diag_size

Font size for labels in diagonal row

lower_size

Font size for labels in lower triangle

Details

The method prints a plot assembled as a combination of grid elements, but reurns it as a gg object.

Author(s)

The FLR Team

Examples

data(ple4)
cohcorrplot(catch.n(ple4))
cohcorrplot(FLCohort(stock.n(ple4)))

Functions create labels for FLSR models

Description

These functions create labels from FLSR models and params to be used, for example, on the legend of the ggplot-based plot method for FLSRs

Usage

eqlabel(model, param)

modlabel(model, param)

Arguments

model

a list of model formulas

param

a list of FLPar objects for the params slot

Examples

data(nsher)
 srs <- FLSRs(sapply(c('ricker', 'bevholt'), function(x) {
   y <- nsher
   model(y) <- x
   return(fmle(y))
 }))
 eqlabel(model=lapply(srs, model),
   param=lapply(srs, params))
 modlabel(model=lapply(srs, model),
   param=lapply(srs, params))

A high-contrast palette to use in ggplotFL

Description

Plot methods defined in the ggplotFL package make use by default of a palette with a high contrast, useful to separate time series or categories. The palette consist of seven colours: red, blue, green, violet, orange, yellow and brown. This palette can be inspected at the [colorbrewe2.org site](http://colorbrewer2.org/?type=qualitative&scheme=Set1&n=7#type=qualitative&scheme=Set1&n=7).

Usage

flpalette

flpalette_colours(n = length(flpalette))

flpalette_grads(palette = flpalette, reverse = FALSE, ...)

scale_colour_flr(palette = flpalette, discrete = TRUE, reverse = FALSE, ...)

Arguments

n

Number of colours or individual colours to return, or number of colours to interpolate.

palette

Palette subset to create a gradual scale from, defaults to *flpalette*.

reverse

Should the palette be reversed, FALSE.

...

Elements to subset from palette, by name or position.

discrete

Is the palette to be applied to a discrete variable, TRUE.

Format

An object of class character of length 8.

Details

The palette is accessible as a named vector, *flpalette*. Two functions are also available to manipualte the palette. One to extract a subset of the palette, *flpalette_colours*, and another to create a gradation of colours between two or more of the palette colours, *flpalette_grads*.

Value

A named vector of colors and HEX codes, or a function to obtain a gradient of colors fo a given length.

Author(s)

The FLR Team

See Also

FLComp

Examples

# CHECK flpalette
 flpalette
 scales::show_col(flpalette)
flpalette_colours()
flpalette_colours(5)
flpalette_colours(2:3)
flpalette_grads(flpalette_colours(3))(20)

Horizontal lines for FLPar objects

Description

This 'geom' shows a horizontal line for each 'param' in a 'FLPar' object and labels it using the 'param' dimnames, by calling 'geom_hline' and 'ggrepel::geom_label_repel'. Separate labels and lines can be specified for different facets by providing the 'data' argument with an object of class 'FLPars' in which each element is named as the values of the facetting variable.

Usage

geom_flpar(mapping = NULL, data, ..., x, na.rm = FALSE)

Arguments

mapping

Set of aesthetic mappings created by aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

x

Position for params labels on the x axis

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

Aesthetics

'geom_flpar' understands the following aesthetics (required aesthetics are in bold). Some aesthetics apply to only one of the two elements, in parenthesis: - '*x*' - 'y', defaults to 90 - 'yintercept', defaults to params value (line). - 'label', defaults to params names. - 'alpha' - 'colour' - 'linetype' (line) - 'linewidth' (line) - 'fill' (label) - 'angle' (label) - 'family' (label)

Examples

data(ple4)
plot(ssb(ple4)) + geom_flpar(data=FLPar(Blim=300000), x=1960)
plot(ssb(ple4)) + geom_flpar(data=FLPar(Blim=300000), x=2015)
plot(ssb(ple4)) + geom_flpar(data=FLPar(Blim=300000, Bpa=230000), x=1960)
# geom works for multiple facets, separate params using name-matching FLPars()
plot(ple4, metrics=list(SSB=ssb, F=fbar)) +
  geom_flpar(data=FLPars(SSB=FLPar(Blim=300000, Bpa=230000),
  F=FLPar(FMSY=0.21)), x=c(1964))
# x and y positions can be altered by param
plot(ple4, metrics=list(SSB=ssb, F=fbar)) +
  geom_flpar(data=FLPars(SSB=FLPar(Blim=300000, Bpa=230000),
  F=FLPar(FMSY=0.21)), x=c(2015, 2015, 1960), y=c(340000, 180000, 0.18))

Sampling quantiles

Description

This 'geom' calculates sampling quantiles and draws a ribbon for the quantile range plus a line for the median (50% quantile).

Usage

geom_flquantiles(
  mapping = NULL,
  data = NULL,
  stat = "FLQuantiles",
  position = "identity",
  show.legend = NA,
  inherit.aes = TRUE,
  na.rm = FALSE,
  probs = c(0.1, 0.5, 0.9),
  alpha = 0.5,
  ...
)

stat_flquantiles(
  mapping = NULL,
  data = NULL,
  geom = "line",
  position = "identity",
  na.rm = TRUE,
  show.legend = NA,
  inherit.aes = TRUE,
  ...
)

Arguments

mapping

Set of aesthetic mappings created by aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

data

The data to be displayed in this layer. There are three options:

If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot().

A data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See fortify() for which variables will be created.

A function will be called with a single argument, the plot data. The return value must be a data.frame, and will be used as the layer data. A function can be created from a formula (e.g. ~ head(.x, 10)).

stat

The statistical transformation to use on the data for this layer, either as a ggproto Geom subclass or as a string naming the stat stripped of the stat_ prefix (e.g. "count" rather than "stat_count")

position

Position adjustment, either as a string naming the adjustment (e.g. "jitter" to use position_jitter), or the result of a call to a position adjustment function. Use the latter if you need to change the settings of the adjustment.

show.legend

logical. Should this layer be included in the legends? NA, the default, includes if any aesthetics are mapped. FALSE never includes, and TRUE always includes. It can also be a named logical vector to finely select the aesthetics to display.

inherit.aes

If FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. borders().

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

probs

Quantiles to compute and draw, defaults to c(0.10, 0.90).

alpha

Transparency for quantile ribbon.

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

geom

The geometric object to use to display the data, either as a ggproto Geom subclass or as a string naming the geom stripped of the geom_ prefix (e.g. "point" rather than "geom_point")

Details

As this 'geom' outputs two layers, although based on different 'geoms', interactions between common parameters need to be considered. The 'fill' parameter will only affect the quantile range 'ribbon', but 'colour' will be passed to both the 'ribbon' and median 'line' layers. The defaults are no lines on the quantiles and "black" for the median line. The 'alpha' value has been hard coded to 1 for the median line, so only affects the quantile 'ribbon'. To change this, call 'stat_flquantiles' directly, as in the examples below.

'stat_flquantiles' will return between one and three 'y' values depending on the number of quantiles requested. If two quantiles are to be calculated, it will return the corresponding 'ymin' and 'ymax', to be used with, for example, 'geom_ribbon'. If only one quantile is to be calculated, it will be returned as 'y', to be used typically by 'geom_line'. Finally, if three values are passed in the 'probs' argument, all of the above will be returned, in the right order.

Aesthetics

'geom_flquantiles' understands the following aesthetics (required aesthetics are in bold): - '*x*' - '*y*' - 'alpha' - 'colour' - 'fill' - 'group' - 'linetype' - 'linewidth' where some of them apply to the ribbons and some of them to the lines.

Computed variables

y

quantile, if only one requested or central one when if three

ymin

lower quantile, if two or three requested

ymax

upper quantile, if two or three requested

Examples

data(ple4)
flq <- rnorm(250, catch(ple4), 200000)
ggplot(flq, aes(x=date, y=data)) +
  geom_flquantiles(probs=c(0.25, 0.50, 0.75), fill="red", alpha=0.25)
# Draw two quantiles with two calls to geom_flquantiles
ggplot(flq, aes(x=date, y=data)) +
  geom_flquantiles(probs=c(0.25, 0.50, 0.75), alpha=0.25, fill="red") +
  geom_flquantiles(probs=c(0.10, 0.90), alpha=0.15, fill="red")
# Use it on an FLQuants, colouring by their name
flqs <- FLQuants(A=rnorm(250, catch(ple4), 200000),
  B=rnorm(250, stock(ple4), 200000))
ggplot(flqs, aes(x=date, y=data, colour=qname)) +
  geom_flquantiles(probs=c(0.10, 0.50, 0.90), aes(fill=qname), alpha=c(0.30))
# Or facet them
ggplot(flqs, aes(x=date, y=data)) +
  geom_flquantiles(probs=c(0.10, 0.50, 0.90), fill="red", alpha=c(0.30)) +
  facet_grid(qname~.)
# For greater control, call stat_flquantiles directly with a geom
ggplot(flq, aes(x=year, y=data)) +
 stat_flquantiles(probs=c(0.10, 0.90), geom = "ribbon",
   fill="yellowgreen", alpha=0.30) +
 stat_flquantiles(probs=c(0.01), geom = "line",
   colour = "green4", linetype=3) +
 stat_flquantiles(probs=c(0.99), geom = "line",
   colour = "green4", linetype=3) +
 stat_flquantiles(probs=c(0.25, 0.75), geom = "ribbon",
   fill="green4", alpha=0.30) +
 stat_flquantiles(probs=c(0.50), geom = "line", linewidth=1.5,
   colour = "lightgreen") +
 stat_flquantiles(probs=c(0.50), geom = "line",
   colour = "darkgreen")

A geom for adding worms to probability intervals from geom_flquantiles

Description

A geom for adding worms to probability intervals from geom_flquantiles

Usage

geom_worm(
  data,
  mapping = aes(colour = iter),
  ...,
  stat = "identity",
  position = "identity",
  na.rm = FALSE
)

Arguments

data

Subset of data, select from full object using iter().

mapping

Set of aesthetic mappings created by aes(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

...

Other arguments passed on to layer(). These are often aesthetics, used to set an aesthetic to a fixed value, like colour = "red" or size = 3. They may also be parameters to the paired geom/stat.

stat

The statistical transformation to use on the data for this layer, either as a ggproto Geom subclass or as a string naming the stat stripped of the stat_ prefix (e.g. "count" rather than "stat_count")

position

Position adjustment, either as a string naming the adjustment (e.g. "jitter" to use position_jitter), or the result of a call to a position adjustment function. Use the latter if you need to change the settings of the adjustment.

na.rm

If FALSE, the default, missing values are removed with a warning. If TRUE, missing values are silently removed.

Aesthetics

'geom_worm' understands the following aesthetics (required aesthetics are in bold): - 'colour' - 'linetype' - 'linewidth'

Examples

data(ple4)
x <- rlnorm(200, log(catch(ple4)), 0.3)
plot(x) + geom_worm(data=iter(x, 1:4))

x <- FLQuants(C=rlnorm(200, log(catch(ple4)), 0.3),
  F=rlnorm(200, fbar(ple4), 0.2))
plot(x) + geom_worm(data=iter(x, 1:4))

ggplot method for various FLR classes

Description

The ggplot() method has been conveniently overloaded for various FLR classes. A call to as.data.frame takes place on data before passing all arguments to the original ggplot function.

Usage

## S4 method for signature 'FLQuant'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

## S4 method for signature 'FLQuants'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

## S4 method for signature 'FLComp'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

## S4 method for signature 'FLComps'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

## S4 method for signature 'FLPar'
ggplot(data = NULL, mapping = aes(), ..., environment = parent.frame())

Arguments

data

An FLQuant object

mapping

An aesthetic mapping, from a call to aes

...

Other arguments to be passod on to ggplot

environment

Where to look for an undefined plot variable.

Details

Please look at the relevant as.data.frame method for each class to understand the naming conventions used in the resulting data.frame

See Also

ggplot, https://github.com/flr/ggplotFL/

Examples

dat <- rnorm(1, FLQuant(1, dim=c(5,10)), 0.5)
   ggplot(data=dat, aes(data, year)) + geom_point() 
   data(ple4)
   dat <- FLQuants(catch=catch(ple4), ssb=ssb(ple4))
   ggplot(data=dat, aes(data, year)) + geom_point() + facet_wrap(~qname)

A ggplot2 number formatter

Description

This function formats numbers for output in a 'human' way.

Usage

human_numbers(x = NULL, smbl = "", signif = 1)

Arguments

x

An object of class numeric

smbl

A character or symbol to be added prior to the number, e.g. an euro sign.

signif

Number of significant figures

Value

A formatted character vector

Author(s)

Iago Mosqueira (EC JRC)

See Also

labeller


Shows integer values in a programmatic and scalable fashion.

Description

This function provides sensible breaks for integers

Usage

integer_breaks(n = 5, ...)

Arguments

n

Number of breaks

...

Arguments to be passed to *pretty*

Value

A function to be called

Author(s)

Iago Mosqueira (WMR)

See Also

labeller pretty


A ggplot2 labeller for FLQuants

Description

Plots of FLQuants objects use by default facet_grid to separate the different elements. This function generates facet labels that have both the element name and the units of measurement of each, as stored in the 'units' slot of each FLQuant.

Usage

label_flqs(x, drop = c("NA", "NC", "m", "f", "z", "prop"))

Arguments

x

An object of class FLQuants

drop

Character string to be dropped from the label shen found in the *units* slot. Defaults to c("NA", "NC", "m", "z", "prop")

Details

Certain *units* are dropped from the label, as being uninformative: "NA", "NC", "m", "z", and "prop". This can be selected with the *drop* argument.

Value

A ggplot2 labeller function

Author(s)

Iago Mosqueira (EC JRC)

See Also

labeller


ggplot versions of FLR class plot() methods

Description

New basic plot methods for some FLR classes are defined in ggplotFL.

Usage

## S4 method for signature 'FLQuant,missing'
plot(x, probs = c(0.05, 0.25, 0.5, 0.75, 0.95), na.rm = FALSE, ...)

## S4 method for signature 'FLQuant,FLQuant'
plot(
  x,
  y,
  ...,
  probs = c(0.05, 0.25, 0.5, 0.75, 0.95),
  na.rm = FALSE,
  iter = NULL
)

## S4 method for signature 'FLQuants,missing'
plot(
  x,
  probs = c(0.05, 0.25, 0.5, 0.75, 0.95),
  na.rm = FALSE,
  worm = iter,
  iter = NULL
)

## S4 method for signature 'FLQuants,FLPar'
plot(x, y, ...)

## S4 method for signature 'FLQuants,FLPars'
plot(x, y, ...)

## S4 method for signature 'FLQuantPoint,missing'
plot(x, mean = TRUE, median = TRUE)

## S4 method for signature 'FLQuantPoint,FLQuant'
plot(x, y, na.rm = FALSE, ...)

## S4 method for signature 'FLQuantPoint,FLQuants'
plot(x, y, na.rm = FALSE, mean = TRUE, median = TRUE, ...)

## S4 method for signature 'FLPar,missing'
plot(x, names = NULL)

## S4 method for signature 'FLStock,missing'
plot(
  x,
  metrics = list(Rec = rec, SSB = ssb, Catch = catch, F = fbar),
  na.rm = TRUE,
  ...
)

## S4 method for signature 'FLStock,FLStock'
plot(
  x,
  y,
  metrics = list(Rec = rec, SSB = ssb, Catch = catch, F = fbar),
  probs = c(0.1, 0.33, 0.5, 0.66, 0.9),
  na.rm = TRUE,
  iter = NULL,
  ...
)

## S4 method for signature 'FLStock,FLPar'
plot(x, y, metrics = list(Rec = rec, SSB = ssb, Catch = catch, F = fbar), ...)

## S4 method for signature 'FLStocks,missing'
plot(
  x,
  metrics = list(Rec = function(x) unitSums(rec(x)), SB = function(x) unitSums(ssb(x)), C
    = function(x) unitSums(catch(x)), F = function(x) unitMeans(fbar(x))),
  probs = c(0.1, 0.33, 0.5, 0.66, 0.9),
  alpha = c(0.1, 0.4),
  worm = iter,
  iter = NULL,
  ...
)

## S4 method for signature 'FLStocks,missing'
plot(
  x,
  metrics = list(Rec = function(x) unitSums(rec(x)), SB = function(x) unitSums(ssb(x)), C
    = function(x) unitSums(catch(x)), F = function(x) unitMeans(fbar(x))),
  probs = c(0.1, 0.33, 0.5, 0.66, 0.9),
  alpha = c(0.1, 0.4),
  worm = iter,
  iter = NULL,
  ...
)

## S4 method for signature 'FLStocks,FLPar'
plot(
  x,
  y,
  na.rm = TRUE,
  metrics = function(x, y) FLQuants(SSB = ssb(x)/y[, "ssb", ], F = fbar(x)/y[, "harvest",
    ], Catch = catch(x))
)

## S4 method for signature 'FLStock,FLStocks'
plot(x, y, ...)

## S4 method for signature 'FLSR,missing'
plot(x, y, ...)

## S4 method for signature 'FLSRs,ANY'
plot(x, legend_label = names(x), facets = FALSE, ...)

## S4 method for signature 'FLBiol,missing'
plot(x, metrics = list(Rec = function(x) n(x)[1, ], B = tsb), ...)

## S4 method for signature 'FLBiols,missing'
plot(x, metrics = list(Rec = function(x) n(x)[1, ], B = tsb), ...)

## S4 method for signature 'FLIndexBiomass,missing'
plot(x, y, ...)

## S4 method for signature 'FLIndex,missing'
plot(x)

## S4 method for signature 'FLIndices,missing'
plot(x)

Arguments

x

FLR object to plot

probs

Quantiles to calculate along the iter dimension. A vector of length 5, for the lower outer, lower inner, central, upper inner and upper outer quantiles. Defaults to the 66 and 80 percent quantiles, plus median line.

na.rm

Should NAs be deleted in quantile calculations?, defaults to TRUE.

...

Other arguments to be passed to the corresponding ggplot call.

y

FLR object to plot

iter

Individual iterations to show as worm plots over the quantiles.

worm

Individual iterations to show as worm plots over the quantiles.

metrics

function returning an FLQuants for each FLStock

alpha

alpha values for the quantile ribbons, defaults to 0.10 and 0.40.

legend_label

function to create the legend labels

Details

The coertion to *data.frame* that is carried out in the plot methods sets the argument 'date=TRUE'. This generates a new column of class 'POSIXct' for the first day of the first month of each season. If the 'season' dimension of the object being plotted is of length greater than one, 'date' will be used as variable on the x axis of the plot. Otherwise, it will be 'year'. Keep this in mind when adding extra elements to the plot (see examples below).

A similar mechanism is used for the *y* axis, depending on the length of the 'iter' dimension. For objects with no *iters*, a single line is plotted for each *FLQuant*, and the *y* axis is mapped to the 'data' column of the *data.frame*. For objects with iterations, i.e. with length greater than 1 on the 'iter' dimension, the default plots show the quantiles of the distribution and the *y* axis is mapped to the middle quantile, by default '50 examples below on how to refer to these variables when adding elements to the plot.

See Also

ISOdate ggplot

Examples

# Plot a single FLQuant
 data(ple4)
 plot(catch.n(ple4))

 # Plot an FLQuant with iters, shows quantiles
 flq <- rnorm(100, catch(ple4), 60000)
 plot(flq)

 # Specify quantiles, default is c(0.10, 0.33, 0.50, 0.66, 0.90)
 plot(flq, probs=c(0.05, 0.25, 0.50, 0.75, 0.95))

 # Adding extra elements to an FLQuant plot, with seasons
 flq <- FLQuant(runif(200), dim=c(1,15,1,4))
 plot(flq) + geom_point(aes(x=date, y=data, colour=season))

# or without them
 flq <- FLQuant(runif(200), dim=c(1,15))
 plot(flq) + geom_point(aes(x=year, y=data))

# For an object with iter
 flq <- rlnorm(100, flq, 0.4)
 plot(flq) + geom_point(aes(x=year, y=data))

# To plot(FLQuant) as in previous versions of ggplotFL
plot(rnorm(300, catch(ple4), catch(ple4)/2), probs=c(0.10, 0.5, 0.90)) +
  geom_flquantiles(probs=c(0.01), linetype=3, colour="red", alpha=0.1) +
  geom_flquantiles(probs=c(0.99), linetype=3, colour="red", alpha=0.1)
# plot(FLQuant, FLQuant, ...) to place in one facet
plot(catch(ple4), landings(ple4))
# Add legend by hand
plot(rnorm(200, landings(ple4), 8000), discards(ple4)) +
  scale_colour_discrete(name="Yield (t)", labels=c("Landings", "Discards")) +
  theme(legend.position="bottom")
 # Plot an FLQuants created from ple4 FLStock
 data(ple4)
 plot(FLQuants(SSB=ssb(ple4), rec=rec(ple4)))
 plot(FLQuants(SSB=ssb(ple4), rec=rec(ple4)), probs = NULL)
 # plot for FLQuants, FLPar
 data(ple4)
 rps <- FLPar(F=0.14, Catch=1.29e5, Rec=9.38e5, SSB=1.8e5)
 fqs <- metrics(ple4)
 plot(fqs, rps)
 # Works also if reptsa are given for some panels
 rps <- FLPar(F=0.14, Catch=1.29e5, SSB=1.8e5)
 plot(fqs, rps)
 # plot for FLQuants, FLPars
 data(ple4)
 rps <- FLPars(F=FLPar(Fmsy=0.14, Fpa=0.35), SSB=FLPar(SBmsy=1.8e5, SBlim=1.1e5))
 fqs <- metrics(ple4, list(SSB=ssb, F=fbar))
 plot(fqs, rps) + ylim(c(0, NA))
# plot for FLQuantPoint
fqp <- FLQuantPoint(rlnorm(300, log(catch(ple4)), 0.20))
plot(fqp)
# plot for FLQuantPoint, FLQuant
plot(fqp, rlnorm(3, log(catch(ple4)), 0.20))
# plot for FLQuantPoint, FLQuants
fqp <- FLQuantPoint(rlnorm(300, log(catch(ple4)), 0.20))
fqs <- divide(rlnorm(3, log(catch(ple4)), 0.20))
plot(fqp, fqs)
par <- FLPar(alpha=rnorm(200, 0.6, 0.2), beta=rlnorm(200, 0.8, 0.3))
plot(par)
# plot of an FLStock
 data(ple4)
 plot(ple4)
# plot for FLStock, FLPar
data(ple4)
rps <- FLPar(F=0.14, Catch=1.29e5, Rec=9.38e5, SSB=1.8e5)
plot(ple4, rps)
# plot for FLStocks
data(ple4)
pls <- FLStocks(runA=ple4, runB=qapply(ple4, function(x) x*1.10))
plot(pls)
# geom_flpar can be used draw refpts lines and labels
plot(pls, metrics=list(SSB=ssb, F=fbar)) +
  facet_grid(qname~stock, scales='free') +
  geom_flpar(data=FLPars(SSB=FLPar(Blim=300000, Bpa=230000),
  F=FLPar(FMSY=0.21)), x=c(1960), stock='runA', fill=alpha('white', 0.4))
# plot for FLStocks
data(ple4)
pls <- FLStocks(runA=ple4, runB=qapply(ple4, function(x) x*1.10))
plot(pls)
# geom_flpar can then be used draw refpts lines and labels
plot(pls, metrics=list(SSB=ssb, F=fbar)) +
  facet_grid(qname~stock, scales='free') +
  geom_flpar(data=FLPars(SSB=FLPar(Blim=300000, Bpa=230000),
  F=FLPar(FMSY=0.21)), x=c(1960), stock='runA', fill=alpha('white', 0.4))
# plot for FLSR
 data(nsher)
 plot(nsher)
 # plot for FLSRs
 data(nsher)
 srs <- FLSRs(sapply(c('segreg', 'bevholt'), function(x) {
   y <- nsher
   model(y) <- x
   return(fmle(y))
 }))
 plot(srs, facets=TRUE)
 plot(srs, legend_label=eqlabel)
 plot(srs, legend_label=modlabel)
 # Plot a FLIndex object
 data(ple4.index)
 plot(ple4.index)
 # Plot a FLIndices object
 data(ple4.indices)
 plot(ple4.indices)
 plot(ple4.indices) +
   geom_smooth(formula=y ~ x, se=FALSE, method="loess", linewidth=0.2)

Plot the runs test result for one or more time series

Description

Plot the runs test result for one or more time series

Usage

plotRunstest(fit, obs, ...)

## S4 method for signature 'FLQuants,missing'
plotRunstest(fit, combine = TRUE)

## S4 method for signature 'FLQuants,FLQuants'
plotRunstest(fit, obs, combine = TRUE)

## S4 method for signature 'FLQuant,FLQuant'
plotRunstest(fit, obs, combine = TRUE)

Arguments

fit

The result of a model fit.

obs

The observations used in the fit.

...

Extra arguments.

combine

Should ages be combined by addition, defaults to TRUE.

Value

An object of class ggplot2::gg

Examples

data(nsher)
plotRunstest(fitted(nsher), rec(nsher))

Plot of FLIndices cross-validation by retrospective hindcast

Description

Plot of FLIndices cross-validation by retrospective hindcast

Usage

plotXval(x, y = "missing", order = "inverse")

Arguments

x

An *FLIndices* object of the original observations.

y

A list contaning *FLIndices* objects returned by *a4ahcxval*.

order

Order in which retrospective runs are stored, defaults to"inverse".

Value

A ggplot object

Examples

# SEE vignette

Output ggplot object to PNG files with good quality settings.

Description

Output ggplot object to PNG files with good quality settings.

Usage

pubpng(file, plot, width = 1600, height = 1400, res = 200)

Arguments

file

Output file path and name.

plot

ggplot object or command.

width

Width of plot, in pixels. Defaults to 1600.

height

Height of plot, in pixels. Defaults to 1400.

res

Resolution, in ppi. Deagults to 200.

Value

TRUE if succesful, while file is saved to disk.

See Also

grDevices::png


High contrast discrete and continuous palettes

Description

Discrete and continuous versions of the standard ggplotFL palette. See flpalette fo further details.

Usage

scale_fill_flr(palette = flpalette, discrete = TRUE, reverse = FALSE, ...)

Arguments

palette

Palette subset to create a gradual scale from, defaults to *flpalette*.

discrete

Is the palette to be applied to a discrete variable, TRUE.

reverse

Should the palette be reversed, FALSE.

...

Other arguments to be passed to the scale functions

Value

A function.

Author(s)

The FLR Team

See Also

flpalette