Skip to content

Commit

Permalink
ggsave(): fix partial argument match
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Dec 8, 2017
1 parent e1ad189 commit 93882e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions R/save.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand Down

0 comments on commit 93882e6

Please sign in to comment.