Learn R Programming

sdbuildR (version 2.0.0)

plot.stockflow: Plot stock-and-flow diagram

Description

Visualize a stock-and-flow diagram using the R package 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 stockflow
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,
  pad = 0.1,
  nodesep = 0.3,
  ...
)

Value

Stock-and-flow diagram

Arguments

x

A stock-and-flow model object of class stockflow.

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 "Times New Roman".

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.

pad

Padding around the graph. Defaults to 0.1.

nodesep

Minimum distance between nodes. Defaults to 0.3.

...

Optional arguments

See Also

import_insightmaker(), stockflow(), plot.simulate_stockflow()

Examples

Run this code
sfm <- stockflow("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")

Run the code above in your browser using DataLab