This vignette compares ggplot2 output rendered directly
with svglite against the same built plot converted through
ggbuild_to_scene() and rendered by
grrr::device_svg().
1) Empty ggplot (baseline)
p_empty <- ggplot() +
theme_minimal(base_size = 8)
cmp_empty <- comparison_block("empty", p_empty)2) Faceted points example (README-style)
p_points <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) +
geom_point() +
facet_wrap(~am) +
theme_minimal(base_size = 5) +
theme(
panel.spacing = grid::unit(4, "mm"),
strip.text = element_text(size = 4),
axis.title = element_text(size = 4.5),
axis.text = element_text(size = 4),
legend.title = element_text(size = 4.5),
legend.text = element_text(size = 4)
)
cmp_points <- comparison_block("points", p_points)What I looked for and found
# Compare key counts in a compact table for both examples.
summary_tbl <- function(label, cmp) {
data.frame(
example = label,
metric = names(cmp$svglite_sig),
svglite = as.numeric(cmp$svglite_sig),
grrr = as.numeric(cmp$grrr_sig),
delta = as.numeric(cmp$grrr_sig) - as.numeric(cmp$svglite_sig)
)
}
tbl <- rbind(
summary_tbl("empty", cmp_empty),
summary_tbl("points", cmp_points)
)
knitr::kable(tbl, align = "lrrrr")| example | metric | svglite | grrr | delta |
|---|---|---|---|---|
| empty | circle | 0 | 0 | 0 |
| empty | polyline | 0 | 0 | 0 |
| empty | polygon | 0 | 0 | 0 |
| empty | line | 0 | 12 | 12 |
| empty | rect | 4 | 1 | -3 |
| empty | text | 0 | 12 | 12 |
| empty | chars | 1329 | 2948 | 1619 |
| points | circle | 35 | 35 | 0 |
| points | polyline | 40 | 0 | -40 |
| points | polygon | 0 | 0 | 0 |
| points | line | 0 | 70 | 70 |
| points | rect | 7 | 4 | -3 |
| points | text | 22 | 18 | -4 |
| points | chars | 12964 | 13322 | 358 |
cat("\n")
cat("- In the empty baseline, layout primitives (rect/line/text) are present on both sides but not necessarily with the same counts due to different internal decomposition.\n")- In the empty baseline, layout primitives (rect/line/text) are present on both sides but not necessarily with the same counts due to different internal decomposition.
cat("- In the faceted points example, circle counts should now be non-zero in grrr and visually present; if not, it indicates a remaining point-shape/size translation issue.\n")- In the faceted points example, circle counts should now be non-zero in grrr and visually present; if not, it indicates a remaining point-shape/size translation issue.
cat("- Gridline density, label placement, and legend drawing can still differ because ggplot's gtable layout and guides are only approximated in the current bridge.\n")- Gridline density, label placement, and legend drawing can still differ because ggplot’s gtable layout and guides are only approximated in the current bridge.