Skip to contents

Visualize the simulation(s) used during verify(). Each condition j is displayed as a subplot. Simulations are always available since verify() unconditionally retains them.

Usage

# S3 method for class 'verify_stockflow'
plot(
  x,
  test = NULL,
  vars = NULL,
  show_constants = FALSE,
  label = NULL,
  ignore_case = TRUE,
  status = c("pass", "fail", "error", "skip"),
  condition = seq(1, min(c(x[["n_conditions"]], 9))),
  nrows = ceiling(sqrt(max(condition))),
  shareX = TRUE,
  shareY = TRUE,
  palette = "Dark 2",
  colors = NULL,
  font_family = "Times New Roman",
  font_size = 16,
  wrap_width = 25,
  showlegend = TRUE,
  label_subplots = TRUE,
  alpha = 1,
  margin = 0.05,
  ...
)

Arguments

x

Output of verify().

test

Integer vector of test numbers to plot. Combines with label and status as AND intersection.

vars

Variables to plot. Defaults to NULL to plot all variables.

show_constants

If TRUE, include constants in plot. Defaults to FALSE.

label

Character vector of regex patterns for partial, case-insensitive label matching. A test is included if its label matches any pattern.

ignore_case

Logical; whether label matching is case-insensitive. Default TRUE.

status

Optional character vector of statuses to include (e.g., c("fail", "error")). Defaults to all statuses.

  • which = "tests": filters rows by test status.

  • which = "sims": filters to conditions that have at least one test with a matching status.

condition

Integer vector of condition numbers to plot. Defaults to 1:9. If only one condition is specified, the plot will not be a grid of subplots.

nrows

Number of subplot rows. Defaults to ceiling(sqrt(condition)).

shareX

Share the x-axis across subplots. Defaults to TRUE.

shareY

Share the y-axis across subplots. Defaults to TRUE.

palette

Colour palette (see hcl.pals()). Defaults to "Dark 2".

colors

Vector of colours overriding palette. Defaults to NULL.

font_family

Font family. Defaults to "Times New Roman".

font_size

Font size. Defaults to 16.

wrap_width

Label wrap width. Defaults to 25.

showlegend

Whether to show the legend. Defaults to TRUE.

label_subplots

Whether to plot labels indicating the test number of the subplot.

alpha

Trajectory opacity. Defaults to 1.

margin

Margin between subplots. Either a single numeric or a vector of length four(left, right, top, bottom). See ?plotly::subplot() for more details. Defaults to 0.05.

...

Additional arguments passed to plot.simulate_stockflow().

Value

A plotly object.

Examples

sfm <- stockflow("SIR") |>
  unit_test(expr = all(susceptible >= 0))
res <- verify(sfm)
plot(res)