plot_generic_situation: Generic plotting of a situation

View source: R/generic_plotting.R

plot_generic_situationR Documentation

Generic plotting of a situation

Description

Plots outputs of a model (and observations) for one situation. This function is used as a generic plotting function for any models. To use it with your own model, please provide a wrapper function around your model to format the outputs used by this function (see format_cropr() for a template), and then provide your custom function as an argument to this one.

Usage

plot_generic_situation(
  sim,
  obs = NULL,
  obs_sd = NULL,
  type = c("dynamic", "scatter"),
  select_dyn = c("sim", "common", "obs", "all"),
  select_scat = c("sim", "res"),
  var = var,
  title = NULL,
  all_situations = TRUE,
  overlap = NULL,
  successive = NULL,
  shape_sit = c("none", "txt", "symbol", "group"),
  situation_group = NULL,
  total_vers = 1,
  num_vers = 1,
  reference_var = NULL,
  force = FALSE,
  verbose = TRUE,
  formater
)

Arguments

sim

A simulation data.frame

obs

An observation data.frame (variable names must match)

obs_sd

A data.frame of standard deviations of observations

select_dyn

Which data to plot when type= "dynamic"? See details.

select_scat

Which data to plot when type= "scatter"? See details.

var

A vector of variables that should be displayed on the graph.

title

The plot title

all_situations

Boolean (default = TRUE). If TRUE, plot all situations on the same graph.

overlap

A list of lists containing the variables to represent on the same graph when type = "dynamic".

successive

A list of lists containing the situations to be represented as a contiguous sequence when type = "dynamic" (implies that the situations are correctly ordered).

shape_sit

Shape to differentiate between situations when all_situations= TRUE. See details.

situation_group

A list of lists of situations to gather when shape_sit= "group".

reference_var

Variable selected on x-axis when type is scatter and select_scat is res. It is possible to select between observation and simulation of the reference variable. (examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim")

force

Continue if the plot is not possible ? E.g. no observations for scatter plots. If TRUE, return NULL, else return an error (default).

verbose

Boolean. Print information during execution.

formater

The function used to format the models outputs and observations in a standard way. You can design your own function that format one situation and provide it here.

Details

The select_dyn argument can be:

  • "sim" (the default): all variables with simulations outputs, and observations when there are some

  • "common": variables with simulations outputs and observations in common

  • "obs": all variables with observations, and simulations outputs when there are some

  • "all": all variables with any observations or simulations outputs

The select_scat argument can be:

  • "sim" (the default): plots observations in X and simulations in Y.

  • "res": plots observations in X and residuals(observations-simulations)in Y.

The shape_sit argument can be:

  • "none" (the default): Same shape for all situations.

  • "txt": Writes the name of the situation above each point.

  • "symbol": One shape for each situation.

  • "group": One shape for each group of situations described in situation_group.

Value

A ggplot object

Note

The error bar will be equal to 2*obs_sd on each side of the point to have 95% confidence.


SticsRPacks/CroPloteR documentation built on May 8, 2024, 5:20 a.m.