Skip to content

Commit d63c64b

Browse files
author
Sebastian Kopf
committed
revert to original
1 parent 47dc611 commit d63c64b

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

R/save.r

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#' @param filename file name/filename of plot
1313
#' @param plot plot to save, defaults to last plot displayed
1414
#' @param device device to use, automatically extract from file name extension
15-
#' (or from paramter \code{ext} if specified)
1615
#' @param path path to save plot to (if you just want to set path and not
1716
#' filename)
1817
#' @param scale scaling factor
@@ -23,9 +22,6 @@
2322
#' @param limitsize when \code{TRUE} (the default), \code{ggsave} will not
2423
#' save images larger than 50x50 inches, to prevent the common error of
2524
#' specifying dimensions in pixels.
26-
#' @param ext file extension to use for choosing the correct device (pdf, jpg, png, etc.),
27-
#' uses extension of the filename by default, specify if filename does not have
28-
#' an instructive extension (or none at all, e.g. in a temporary file)
2925
#' @param ... other arguments passed to graphics device
3026
#' @export
3127
#' @examples
@@ -40,9 +36,9 @@
4036
#' ggsave("ratings.pdf", ratings, scale=2)
4137
#' }
4238
ggsave <- function(filename = default_name(plot), plot = last_plot(),
43-
device = default_device(ext), path = NULL, scale = 1,
39+
device = default_device(filename), path = NULL, scale = 1,
4440
width = par("din")[1], height = par("din")[2], units = c("in", "cm", "mm"),
45-
dpi = 300, limitsize = TRUE, ext = default_ext(filename), ...) {
41+
dpi = 300, limitsize = TRUE, ...) {
4642

4743
if (!inherits(plot, "ggplot")) stop("plot should be a ggplot2 plot")
4844

@@ -73,14 +69,10 @@ ggsave <- function(filename = default_name(plot), plot = last_plot(),
7369
paste(digest.ggplot(plot), ".pdf", sep="")
7470
}
7571

76-
default_ext <- function(filename) {
72+
default_device <- function(filename) {
7773
pieces <- strsplit(filename, "\\.")[[1]]
7874
ext <- tolower(pieces[length(pieces)])
79-
}
80-
81-
default_device <- function(ext) {
82-
tryCatch(match.fun(ext), error = function(e)
83-
stop(sprintf("Cannot find a graphics device that matches file extension '%s'.", ext)))
75+
match.fun(ext)
8476
}
8577

8678
units <- match.arg(units)

0 commit comments

Comments
 (0)