Last active
March 15, 2016 20:19
-
-
Save wabarr/bf1a22abe0e26031b707 to your computer and use it in GitHub Desktop.
simple function to export a plot to EPS, with possible options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## updated with input from @richfitz and @hadley - Thanks, guys!! | |
export_eps <- function(filename, expression, ...){ | |
old <- setEPS() | |
on.exit(do.call(ps.options, old), add = TRUE) | |
postscript(filename, ...) | |
on.exit(dev.off(), add = TRUE) | |
expression | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Function arguments are lazily evaluated. So the plot expression won't actually be executed until it is called inside the function.