acl_save_plot()
View source ↗On this page
Save a plot at its recommended size, at 300 dpi on a white background.
Usage
acl_save_plot(
plot,
filename,
width = NULL,
height = NULL,
dpi = 300,
units = "in",
...
)
Arguments
| Argument | Default | Description |
|---|---|---|
plot | required | A ggplot or patchwork object. |
filename | required | Character. File to write; the extension chooses the format, as in |
width | NULL | Numeric or NULL. Width in |
height | NULL | Numeric or NULL. Height in |
dpi | 300 | Numeric. Resolution of raster formats in dots per inch, 300 by default. |
units | "in" | Character. Unit of width and height, |
... | … | Further arguments of |
Value
The file name, invisibly.
Details
A width or height that is not given comes from acl_figure_size(); a given width gets the height computed for it. The extension of filename chooses the format, as in ggplot2::ggsave(), and further arguments such as device are passed to it. run_acl() and run_alscl() save the figures of output = TRUE with this function.
Examples
Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.
Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
# Use objects defined above
acl_save_plot(plot_SSB(a, se = TRUE), tempfile(fileext = ".png"))
acl_save_plot(plot_compare_ts(a, b), tempfile(fileext = ".pdf"), width = 8)