reno.diagrams#

Functions for generating stock & flow diagrams.

Diagrams are graphviz dot diagrams, and notably don’t follow the exact format typically used with SFDs, namely sources and sinks aren’t explicitly represented.

Module Attributes

DARK_MODE

When True, set graph node_attr to use colors more suited for dark backgrounds.

SUBGRAPH_COLORS

Container background colors for nested models/submodels, each subsquent level will go one color farther into this array.

NODE_COLOR

Background color to use for variable nodes.

Functions

add_flows(g, flows, variables[, sparkall, ...])

Add flows and edges from variables to the passed graphviz graph.

add_stock_io_edge(g, stock, flow)

Edge with attributes for heavily highlighting in flows and outflows from stocks.

add_stock_limit_edge(g, ref, stock)

De-emphasize stock variable/flow connections if they're only used in min/max constraints.

add_stocks(g, stocks[, sparklines, traces, ...])

Add nodes and edges for all passed stocks to the passed graph.

add_to_flow_edge(g, ref, flow)

Non-stock-inflow/outflow-related edges that point to flows are slightly de-emphasized.

add_to_var_edge(g, ref, variable)

Edges pointing at variables are de-emphasized (usually these are auxiliary variables - variables calculated based on other variables.)

add_vars(g, variables, exclude_vars[, ...])

Add variables and edges between variables to the passed graphviz graph.

draw_appropriate_edge(g, src, dst)

Switch between edge types correctly based on the types of src/dst nodes.

filter_variables(all_variables, exclude_names)

Take a list of variables and a list of names of variables to remove from the list.

set_dark_mode([dark])

Set themeing constants for the diagrams appropriately for dark/light theme.

stock_flow_diagram(model[, show_vars, ...])

Generate a graphviz dot graph for all the stocks and flows of the passed model, optionally including sparklines if a simulation has been run.