pdf_pages() writes several plots into one PDF, one plot per page — a report,
a slide deck, or one page per facet. It is the multi-page companion of
render_plot() (which writes a single page). Pages may differ in size (each
plot keeps its own width/height), and the per-page accessibility tags
(structure tree + Alt, see the Accessibility article) are written for
every page.
Arguments
- x
Either a list of plots (each a PlotSpec, composition, or table) — one page each — or a single faceted
PlotSpec, in which case it is split into one page per facet cell (the facet is dropped and the data filtered per page; each page trains its own scales).- path
Output
.pdfpath.
Examples
p1 <- vplot(mtcars) |> mark_point(x = wt, y = mpg)
p2 <- vplot(mtcars) |> mark_histogram(x = mpg, bins = 8)
f <- tempfile(fileext = ".pdf")
pdf_pages(list(p1, p2), f)
# one page per facet cell:
faceted <- vplot(mtcars) |> mark_point(x = wt, y = mpg) |> facet_wrap(~cyl)
pdf_pages(faceted, tempfile(fileext = ".pdf"))
