Skip to contents

Save a plot of a stock-and-flow diagram or a simulation to a specified filepath.

Usage

export_plot(pl, filepath, width = 3, height = 4, units = "cm", dpi = 300)

Arguments

pl

Plot object.

filepath

Filepath to save plot to.

width

Width of image in units.

height

Height of image in units.

units

Units in which width and heigth are specified. Either "cm", "in", or "px".

dpi

Resolution of image. Only used if units is not "px".

Examples

sfm = xmile("SIR")
filepath = tempfile(fileext  = ".png")
export_plot(plot(sfm), filepath)

# Remove plot
file.remove(filepath)
#> [1] TRUE

if (FALSE) { # not_on_cran() & interactive()
sim = simulate(sfm)
export_plot(plot(sim), filepath)

# Remove plot
file.remove(filepath)
}