| plot.sdbuildR_sim | R Documentation |
Visualize simulation results of a stock-and-flow model. Plot the evolution of stocks over time, with the option of also showing other model variables.
## S3 method for class 'sdbuildR_sim'
plot(
x,
add_constants = FALSE,
vars = NULL,
palette = "Dark 2",
colors = NULL,
font_family = "Times New Roman",
font_size = 16,
wrap_width = 25,
showlegend = TRUE,
...
)
x |
Output of simulate(). |
add_constants |
If TRUE, include constants in plot. Defaults to FALSE. |
vars |
Variables to plot. Defaults to NULL to plot all variables. |
palette |
Colour palette. Must be one of hcl.pals(). |
colors |
Vector of colours. If NULL, the color palette will be used. If specified, will override palette. The number of colours must be equal to the number of variables in the simulation data frame. Defaults to NULL. |
font_family |
Font family. Defaults to "Times New Roman". |
font_size |
Font size. Defaults to 16. |
wrap_width |
Width of text wrapping for labels. Must be an integer. Defaults to 25. |
showlegend |
Whether to show legend. Must be TRUE or FALSE. Defaults to TRUE. |
... |
Optional parameters |
Plotly object
simulate(), as.data.frame.sdbuildR_sim(), plot.sdbuildR_xmile()
sfm <- xmile("SIR")
sim <- simulate(sfm)
plot(sim)
# The default plot title and axis labels can be changed like so:
plot(sim, main = "Simulated trajectory", xlab = "Time", ylab = "Value")
# Add constants to the plot
plot(sim, add_constants = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.