save_bayesqm_plot: Save a bayesqm plot to file

View source: R/save_plot.R

save_bayesqm_plotR Documentation

Save a bayesqm plot to file

Description

Opens a graphics device chosen from the file extension (.pdf, .svg, .png, .tiff, .jpeg), evaluates expr so whatever it draws lands on that device, and closes the device. expr is lazily evaluated, so a call like save_bayesqm_plot("fig.pdf", plot(fit)) does not draw to the current screen device first. If expr returns a ggplot object (for example, from ggplot2::autoplot()), it is print()ed onto the device.

Usage

save_bayesqm_plot(file, expr, width = 7.2, height = 5, dpi = 300)

Arguments

file

Output path. Extension determines the device.

expr

Plotting expression (lazily evaluated).

width, height

Dimensions in inches. Defaults to a 7.2 x 5 inch two-column journal figure.

dpi

Resolution for raster formats (png, tiff, jpeg).

Value

The file path, invisibly.

Examples

fit <- demo_fit(N = 6, J = 10, K = 2, Td = 50, seed = 1)
f <- file.path(tempdir(), "fig_loadings.pdf")
save_bayesqm_plot(f, plot_loading_posterior(fit))
unlink(f)


bayesqm documentation built on June 18, 2026, 1:07 a.m.