View source: R/expect_snapshot_doc.R
| expect_snapshot_ggplots | R Documentation |
Renders ggplot2 objects to PNG with ragg and compares
against a reference snapshot using expect_snapshot_doc().
When x is a list of ggplot2 objects, individual renderings are
assembled into a single composite image via images_to_miniature().
By default each plot occupies its own row; use ncol to arrange
several plots per row. The snapshot is always a single file
named <name>.png, stored in testthat's _snaps directory.
If a plot fails to render, its slot is replaced by a blank white rectangle of the same dimensions, making the failure visible in the diff.
On the first run the reference snapshot is created and the test is reported as a new snapshot. Subsequent runs compare the current rendering against the stored reference.
expect_snapshot_ggplots(
x,
name,
width = 9,
height = 7,
units = "in",
res = 200,
ncol = NULL,
tolerance = 0.001
)
x |
a ggplot2 object or a list of ggplot2 objects. |
name |
a unique string used as the snapshot file name
( |
width, height |
image dimensions (default 9 x 7 inches). |
units |
units for width/height, default "in". |
res |
resolution in DPI, default 200. |
ncol |
number of images per row in the composite when |
tolerance |
ratio of different pixels allowed, default 0.001. |
The result of expect_snapshot_doc().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.