Skip to content

Commit b682c8a

Browse files
committed
allow saving pages
1 parent f468053 commit b682c8a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

R/save.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ggsave <- function(filename, plot = get_last_plot(),
102102
dim <- plot_dim(c(width, height), scale = scale, units = units,
103103
limitsize = limitsize, dpi = dpi)
104104

105-
if (is_null(bg)) {
105+
if (is_null(bg) && is.ggplot(plot)) {
106106
bg <- calc_element("plot.background", plot_theme(plot))$fill %||% "transparent"
107107
}
108108
old_dev <- grDevices::dev.cur()
@@ -111,7 +111,10 @@ ggsave <- function(filename, plot = get_last_plot(),
111111
grDevices::dev.off()
112112
if (old_dev > 1) grDevices::dev.set(old_dev) # restore old device unless null device
113113
}))
114-
grid.draw(plot)
114+
if (!is_bare_list(plot)) {
115+
plot <- list(plot)
116+
}
117+
lapply(plot, grid.draw)
115118

116119
invisible(filename)
117120
}

0 commit comments

Comments
 (0)