R/plot_functions.R
verify_plot_arguments.Rd
Used internally by the plotting functions to check that the arguments are structured appropriately.
verify_plot_arguments(
data,
x,
y,
horiz,
horiz2,
vert,
vert2,
color,
relative.error,
axes.free,
print
)
A valid data frame containing scalar or timeseries values
from a ss3sim simulation. That data are generated from
get_results_all
.
A character string denoting which column to use as the x variable.
For time-series data, setting x = "year"
leads to a time-series plot.
A character string denoting which column to use as the y variable. Must be a numeric column.
A character string denoting which column to use as
the first (horiz
) and second (horiz2
) level of faceting in
the horizontal direction. E.g., "M" or "species". A value of NULL (default)
indicates no faceting in the horizontal space.
A character string denoting which column to use as
the first (vert
) and second (vert2
) level of faceting in
the vertical direction. E.g., "M" or "species". A value of NULL (default)
indicates no faceting in the vertical space.
A character string denoting which column to use to map color. Not valid for boxplot functions. Useful for looking at EM performance criteria against other dimensions of the EM or OM. See example below for how to merge in a metric from a scalar dataset to a ts dataset.
Boolean for whether the y-axis scale should be
interpreted as relative error. If TRUE
, ylim
is set to
c(-1, 1)
, the y-axis label is changed automatically, and a
black, dashed line at y=0
is added. The argument can also accept a
color entry if you wish the line to be something other than black. E.g.,
"red"
will add a red dashed line at zero as well as fix the y-axis
limits.
Boolean for whether the y-axis scales should be free
in facet_grid
.
A logical for whether the plot is printed or not.
Nothing is returned; an informative error is thrown if an argument is invalid.
The ss3sim plotting functions are simply
wrappers for ggplot2 code, specific to the output from
ss3sim get_results_all()
objects. They are
designed to quickly explore simulation output, rather than produce
publication-level figures. The functions use arguments passed as
characters that refer to columns of data
.
Scalar plots requires a value for x
; while,
for time-series plots, x = "year"
will be necessary.
Note that there are some subtle differences between the
functions.
Boxplots cannot have a color mapped to them like points or lines,
and thus, color
is not a
valid argument. The time-series point and line plots are grouped internally by
'ID', which is a combination of scenario and iteration and will be
automatically added to the data set if not already present.
These functions print the ggplot
object, but
also return it invisibly for saving or printing again later.
For example, you could save the ggplot
object and add a custom
theme or change an axis label before printing it.