View source: R/moplot_export.R
| moplot_export | R Documentation |
moplot_export() exports a plot created by moplot_onepred() or
moplot_multpred() using dimensions recommended from the graphical
complexity of the plot: the number of displayed quantities (or of
polynomial components and levels), the depth of the interaction
hierarchy, and the presence of the coefficient panel.
PNG and TIFF files are exported at high resolution. TIFF files use lossless LZW compression. PDF files are exported through the Cairo device to improve rendering of Unicode symbols used in MoPlot figures.
moplot_export(
plot,
filename,
width = NULL,
height = NULL,
dpi = 600,
bg = "white"
)
plot |
A plot object created by |
filename |
Character string specifying the output filename. Supported
extensions are |
width |
Optional export width in inches. If |
height |
Optional export height in inches. If |
dpi |
Resolution in dots per inch for raster formats. The default is
|
bg |
Background colour. The default is |
Invisibly returns the normalized path of the exported file.
set.seed(123)
dat <- data.frame(
group = factor(rep(c("A", "B", "C"), each = 20)),
y = rnorm(60, mean = rep(c(0, 0.4, 0.9), each = 20))
)
contrasts(dat$group) <- contr.helmert(3)
plot <- moplot_onepred(
model = lm(y ~ group, data = dat),
predictor = "group",
caption = FALSE
)
# Recommended dimensions, stored in the plot.
attr(plot, "moplot_export_size")
path <- moplot_export(
plot,
filename = file.path(tempdir(), "moplot.png"),
dpi = 150
)
file.exists(path)
unlink(path)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.