canvas | R Documentation |
A canvas specification essentially comprises a set of parameters
from ggplot2::ggsave()
. When a plot with this canvas specification is
printed, it is rendered as it would appear if saved to a file with the
specified dimensions.
canvas(
width,
height,
units = c("in", "cm", "mm", "px"),
dpi = 300,
scale = 1,
bg = "white"
)
width , height |
Plot size in units expressed by the |
units |
One of the following units in which the |
dpi |
Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types. |
scale |
Multiplicative scaling factor. |
bg |
Background colour. If |
An object of class canvas
that can be added to a ggplot
object
to specify the plot dimensions.
library(ggplot2)
p <-
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
ggtitle("My awesome plot")
p + canvas(3, 3)
p + canvas(5, 3, dpi = 400)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.