plot_hisafe_ts: Plot timeseries of Hi-sAFe output variable

Description Usage Arguments Value See Also Examples

View source: R/plot.R

Description

Plots a daily timeseries of a single Hi-sAFe output variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
plot_hisafe_ts(
  hop,
  variables,
  profile,
  cumulative = FALSE,
  simu.names = "all",
  years = "all",
  tree.ids = "all",
  date.min = NA,
  date.max = NA,
  doy.lim = c(1, 365),
  color.palette = NA,
  linetype.palette = NA,
  aes.cols = list(color = "SimulationName", linetype = "SimulationName"),
  facet.simu = FALSE,
  facet.year = FALSE,
  facet.crop = FALSE,
  intercrop = TRUE,
  crop.points = FALSE,
  plot = TRUE,
  save = FALSE,
  output.path = NULL
)

Arguments

hop

An object of class hop.

variables

A character vector of the names of the variables to plot. More than one variable name can be passed, but all variables must be from the same profile.

profile

A character string of the profile for which to plot a timeseries. One of 'trees', 'plot', 'climate', or 'cells'.

cumulative

Logical indicating wheter variables should be cumulated before plotting.

simu.names

A character vector of the SimulationNames within hop to include. Use "all" to include all available values.

years

A numeric vector of the years within hop to include. Use "all" to include all available values.

tree.ids

A numeric vector indicating a subset of tree ids to plot. Use "all" to include all available values.

date.min

A character string of the minimum date to keep, in the format "YYYY-MM-DD" or of class Date. If NA, the minimum date in the output data is used.

date.max

A character string of the maximum date to keep, in the format "YYYY-MM-DD" or of class Date. If NA, the maximum date in the output data is used.

doy.lim

A numeric vector of length two providing the c(minimum, maximum) of julian days to plot. Only applies if profile is a daily profile.

color.palette

A character string of hex values or R standard color names defining the color palette to use in plots with multiple simulations. If NA, the default, then the default color palette is a color-blind-friendly color palette. The default supports up to 48 simulations.

linetype.palette

A character string of values defining the linetype palette to use in plots with multiple simulations. If NA, the default, then solid lines are used for all simulations. The default supports up to 48 simulations.

aes.cols

A list with arguments "color" and "linetype" containing character strings of the column names to use for plot aesthetics.

facet.simu

A logical indicating whether the plot should be faceted by SimulationName This helps when values among simulations are overplotted.

facet.year

A logical indicating whether the plot should be faceted by year. This helps with seeing finer level detail.

facet.crop

A logical indicating whether the plot should be faceted by cropType (mainCrop vs. interCrop). Only applies when profile is 'cells'.

intercrop

A logical indicating whether the plot should include the interCrop cropType. Only applies when profile is 'cells'.

crop.points

Logical indicating if points should be plotted as well, with point shape desgnating the main crop name. Only applies when profile is 'plot'.

plot

If TRUE, the default, a ggplot object is returned. If FALSE, the data that would create the plot is returned.

save

If FALSE, the default, a ggplot object is returned. If TRUE, a ggplot object is returned invisibly and the plot is saved to output.path.

output.path

A character string indicating the path to the directory where plots should be saved. If NULL, the experiment/simulation path is read from the hop object, and a directory is created there called "analysis/misc". The tables and plots will be saved in this directory.

Value

If plot = TRUE, returns a ggplot object, otherwise the data that would create the plot is returned. If the data contains two more tree ids, the plot will be faceted by idTree. Otherwise, if facet.year = TRUE, plots of daily profiles will be faceted by year. If more than one value is passed to variable, then one plot will be created for each variable and combined using cowplot::plot_grid.

See Also

Other hisafe plot functions: plot_hisafe_annualcells(), plot_hisafe_bg(), plot_hisafe_cells(), plot_hisafe_monthcells(), plot_hisafe_scene(), plot_hisafe_tstress(), plot_hisafe_voxels()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# After reading in Hi-sAFe simulation data via:
mydata <- read_hisafe(path = "./")

# For a daily timeseries:
daily.plot <- plot_hisafe_ts(mydata, "carbonCoarseRoots", "trees")

# Once you have the plot object, you can display it and save it:
daily.plot
ggplot2::ggsave("carbonCoarseRoots.png", daily.plot)

## End(Not run)

kevinwolz/hisafer documentation built on Oct. 19, 2020, 4:43 p.m.