Skip to contents

Visualize a stock-and-flow diagram using DiagrammeR. Stocks are represented as boxes. Flows are represented as arrows between stocks and/or double circles, where the latter represent what it outside of the model boundary. Thin grey edges indicate dependencies between variables. By default, constants (indicated by italic labels) are not shown. Hover over the variables to see their equations.

Usage

# S3 method for class 'sdbuildR_xmile'
plot(
  x,
  vars = NULL,
  format_label = TRUE,
  wrap_width = 20,
  font_size = 18,
  font_family = "Times New Roman",
  stock_col = "#83d3d4",
  flow_col = "#f48153",
  dependency_col = "#999999",
  show_dependencies = TRUE,
  show_constants = FALSE,
  show_aux = TRUE,
  minlen = 2,
  ...
)

Arguments

x

Stock-and-flow model of class sdbuildR_xmile

vars

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

format_label

If TRUE, apply default formatting (removing periods and underscores) to labels if labels are the same as variable names.

wrap_width

Width of text wrapping for labels. Must be an integer. Defaults to 20.

font_size

Font size. Defaults to 18.

font_family

Font name. Defaults to "Georgia".

stock_col

Colour of stocks. Defaults to "#83d3d4".

flow_col

Colour of flows. Defaults to "#f48153".

dependency_col

Colour of dependency arrows. Defaults to "#999999".

show_dependencies

If TRUE, show dependencies between variables. Defaults to TRUE.

show_constants

If TRUE, show constants. Defaults to FALSE.

show_aux

If TRUE, show auxiliary variables. Defaults to TRUE.

minlen

Minimum length of edges; must be an integer. Defaults to 2.

...

Optional arguments

Value

Stock-and-flow diagram plotted with DiagrammeR()

Examples

sfm <- xmile("SIR")
plot(sfm)
# Don't show constants or auxiliaries plot(sfm, show_constants = FALSE, show_aux = FALSE)
# Only show specific variables plot(sfm, vars = "Susceptible")