plot.lefkoProj: Plot Projection Simulations

View source: R/popdyn.R

plot.lefkoProjR Documentation

Plot Projection Simulations

Description

Function plot.lefkoProj() produces plots of lefkoProj objects. Acts as a convenient wrapper for the plot.default() function.

Usage

## S3 method for class 'lefkoProj'
plot(
  x,
  variable = "popsize",
  style = "time",
  repl = "all",
  patch = "pop",
  auto_ylim = TRUE,
  auto_col = TRUE,
  auto_lty = TRUE,
  auto_title = FALSE,
  ...
)

Arguments

x

A lefkoProj object.

variable

The focus variable of the plot to produce. Defaults to "popsize", which produces line plots of the popsize element in object x.

style

A string denoting ther kind of plot to produce. Currently limited to "timeseries", which shows variable against time on the x axis. Other choices include "statespace", which plots variable at one time on the x axis against the same variable in the next time on the y axis.

repl

The replicate to plot. Defaults to "all", in which case all replicates are plotted.

patch

The patch to plot, as labeled in the labels element in object x. Defaults to "pop", in which case only the final population-level projection is plotted. Can also be set to "all", in which case projections for all patches and population in the labels element are plotted.

auto_ylim

A logical value indicating whether the maximum of the y axis should be determined automatically. Defaults to TRUE, but reverts to FALSE if any setting for ylim is given.

auto_col

A logical value indicating whether to shift the color of lines associated with each patch automatically. Defaults to TRUE, but reverts to FALSE if any setting for col is given.

auto_lty

A logical value indicating whether to shift the line type associated with each replicate automatically. Defaults to TRUE, but reverts to FALSE if any setting for lty is given.

auto_title

A logical value indicating whether to add a title to each plot. The plot is composed of the concatenated population and patch names. Defaults to FALSE.

...

Other parameters used by functions plot.default() and lines().

Value

A plot of the results of a projection3() run.

Notes

Output plots are currently limited to time series and state space plots of population size.

The default settings will preferentially plot any projections marked as 0 in the patch portion of the labels element of the input MPM. This can produce confusing results if a mean MPM resulting from the lmean() function is used as input and the add_mean setting is set to the default, which is TRUE.

Examples

data(lathyrus)

sizevector <- c(0, 100, 13, 127, 3730, 3800, 0)
stagevector <- c("Sd", "Sdl", "VSm", "Sm", "VLa", "Flo", "Dorm")
repvector <- c(0, 0, 0, 0, 0, 1, 0)
obsvector <- c(0, 1, 1, 1, 1, 1, 0)
matvector <- c(0, 0, 1, 1, 1, 1, 1)
immvector <- c(1, 1, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 100, 11, 103, 3500, 3800, 0.5)

lathframe <- sf_create(sizes = sizevector, stagenames = stagevector,
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
  propstatus = propvector)

lathvert <- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
  patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
  juvcol = "Seedling1988", sizeacol = "Volume88", repstracol = "FCODE88",
  fecacol = "Intactseed88", deadacol = "Dead1988",
  nonobsacol = "Dormant1988", stageassign = lathframe, stagesize = "sizea",
  censorcol = "Missing1988", censorkeep = NA, censor = TRUE)

lathrepm <- matrix(0, 7, 7)
lathrepm[1, 6] <- 0.345
lathrepm[2, 6] <- 0.054

lathsupp3 <- supplemental(stage3 = c("Sd", "Sd", "Sdl", "Sdl", "Sd", "Sdl"), 
  stage2 = c("Sd", "Sd", "Sd", "Sd", "rep", "rep"),
  stage1 = c("Sd", "rep", "Sd", "rep", "all", "all"), 
  givenrate = c(0.345, 0.345, 0.054, 0.054, NA, NA),
  multiplier = c(NA, NA, NA, NA, 0.345, 0.054),
  type = c(1, 1, 1, 1, 3, 3), type_t12 = c(1, 2, 1, 2, 1, 1),
  stageframe = lathframe, historical = TRUE)

ehrlen3 <- rlefko3(data = lathvert, stageframe = lathframe,
  year = c(1989, 1990), stages = c("stage3", "stage2", "stage1"),
  repmatrix = lathrepm, supplement = lathsupp3, yearcol = "year2",
  indivcol = "individ")

lathproj <- projection3(ehrlen3, nreps = 5, stochastic = TRUE)
plot(lathproj)


lefko3 documentation built on May 29, 2024, 6:39 a.m.