Converts a ggplot2 plot, gt table, or carbon.js code image to a
magick-image, ready for warping or compositing. Dispatches automatically
based on the class of x.
Arguments
- x
A ggplot2 (
"ggplot"), gt ("gt_tbl"), or magick image object (fromcarbon_image()).- width
Width of the output image in pixels. Default
400.- height
Height of the output image in pixels. Default
300.- bg
Background color passed to the graphics device. Use
"transparent"(default) to keep alpha when compositing. Note: gt objects rendered viagt::gtsave()may not fully honor a transparent background; in that case use a dark colour such as"#00000000"and accept the white panel, or style the gt table background directly. Forcarbon_image()objects this argument is ignored because carbon.js controls its own background viabg_color.- res
Resolution in DPI used when rasterizing the plot. Default
150. Ignored forcarbon_image()objects.- ...
Additional arguments, currently unused but reserved for future extensions.
Examples
if (FALSE) { # \dontrun{
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
img <- render_hud(p, width = 500, height = 350)
# Carbon code block
code_img <- carbon_image('fit <- lm(mpg ~ wt, data = mtcars)\\nsummary(fit)')
img <- render_hud(code_img, width = 600, height = 300)
} # }
