The WebP format is a raster image format that provides improved lossless (and lossy) compression for images on the web. Transparency is supported.
agg_webp(
filename = "Rplot%03d.webp",
width = 480,
height = 480,
units = "px",
pointsize = 12,
background = "white",
res = 72,
scaling = 1,
snap_rect = TRUE,
lossy = FALSE,
quality = 80,
bg
)
The name of the file. Follows the same semantics as the file
naming in grDevices::png()
, meaning that you can provide a sprintf()
compliant string format to name multiple plots (such as the default value)
The dimensions of the device
The unit width
and height
is measured in, in either pixels
('px'
), inches ('in'
), millimeters ('mm'
), or centimeter ('cm'
).
The default pointsize of the device in pt. This will in general not have any effect on grid graphics (including ggplot2) as text size is always set explicitly there.
The background colour of the device
The resolution of the device. This setting will govern how device dimensions given in inches, centimeters, or millimeters will be converted to pixels. Further, it will be used to scale text sizes and linewidths
A scaling factor to apply to the rendered line width and text
size. Useful for getting the right dimensions at the resolution that you
need. If e.g. you need to render a plot at 4000x3000 pixels for it to fit
into a layout, but you find that the result appears to small, you can
increase the scaling
argument to make everything appear bigger at the
same resolution.
Should axis-aligned rectangles drawn with only fill snap to the pixel grid. This will prevent anti-aliasing artifacts when two rectangles are touching at their border.
Use lossy compression. Default is FALSE
.
An integer between 0
and 100
defining either the quality
(if using lossy compression) or the compression effort (if using lossless).
Same as background
for compatibility with old graphic device APIs
file <- tempfile(fileext = '.webp')
agg_webp(file)
plot(sin, -pi, 2*pi)
dev.off()
Run the code above in your browser using DataLab