Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow saving PDF pages #6187

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions R/save.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ggsave <- function(filename, plot = get_last_plot(),
dim <- plot_dim(c(width, height), scale = scale, units = units,
limitsize = limitsize, dpi = dpi)

if (is_null(bg)) {
if (is_null(bg) && is.ggplot(plot)) {
teunbrand marked this conversation as resolved.
Show resolved Hide resolved
bg <- calc_element("plot.background", plot_theme(plot))$fill %||% "transparent"
}
old_dev <- grDevices::dev.cur()
Expand All @@ -111,7 +111,10 @@ ggsave <- function(filename, plot = get_last_plot(),
grDevices::dev.off()
if (old_dev > 1) grDevices::dev.set(old_dev) # restore old device unless null device
}))
grid.draw(plot)
if (!is_bare_list(plot)) {
plot <- list(plot)
}
lapply(plot, grid.draw)
teunbrand marked this conversation as resolved.
Show resolved Hide resolved

invisible(filename)
}
Expand Down