From 93882e6bf30c36933f4bf9d463063c7f1daa2d41 Mon Sep 17 00:00:00 2001 From: Winston Chang Date: Fri, 8 Dec 2017 11:05:32 -0600 Subject: [PATCH] ggsave(): fix partial argument match --- NEWS.md | 2 ++ R/save.r | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 358690cfe2..4d796290b1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -253,6 +253,8 @@ up correct aspect ratio, and draws a graticule. * `ggsave()`'s DPI argument now supports 3 string options: "retina" (320 DPI), "print" (300 DPI), and "screen" (72 DPI) (@foo-bar-baz-qux, #2156). +* Fixed partial argument matches in `ggsave()`. (#2355) + * `ggsave()` now correctly restores the previous graphics device when several graphics devices are open. (#2363) diff --git a/R/save.r b/R/save.r index 418f36e41a..7848f7e77e 100644 --- a/R/save.r +++ b/R/save.r @@ -54,7 +54,7 @@ ggsave <- function(filename, plot = last_plot(), filename <- file.path(path, filename) } old_dev <- dev.cur() - dev(file = filename, width = dim[1], height = dim[2], ...) + dev(filename = filename, width = dim[1], height = dim[2], ...) on.exit(utils::capture.output({ grDevices::dev.off() dev.set(old_dev) @@ -120,16 +120,16 @@ plot_dev <- function(device, filename, dpi = 300) { if (is.function(device)) return(device) - eps <- function(...) { - grDevices::postscript(..., onefile = FALSE, horizontal = FALSE, + eps <- function(filename, ...) { + grDevices::postscript(file = filename, ..., onefile = FALSE, horizontal = FALSE, paper = "special") } devices <- list( eps = eps, ps = eps, - tex = function(...) grDevices::pictex(...), - pdf = function(..., version = "1.4") grDevices::pdf(..., version = version), - svg = function(...) svglite::svglite(...), + tex = function(filename, ...) grDevices::pictex(file = filename, ...), + pdf = function(filename, ..., version = "1.4") grDevices::pdf(file = filename, ..., version = version), + svg = function(filename, ...) svglite::svglite(file = filename, ...), emf = function(...) grDevices::win.metafile(...), wmf = function(...) grDevices::win.metafile(...), png = function(...) grDevices::png(..., res = dpi, units = "in"),