Created
April 16, 2012 16:01
-
-
Save sheymann/2399659 to your computer and use it in GitHub Desktop.
R tip: Export a ggplot plot in PDF, EPS and PNG files
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
ExportPlot <- function(gplot, filename, width=2, height=1.5) { | |
# Export plot in PDF and EPS. | |
# Notice that A4: width=11.69, height=8.27 | |
ggsave(paste(filename, '.pdf', sep=""), gplot, width = width, height = height) | |
postscript(file = paste(filename, '.eps', sep=""), width = width, height = height) | |
print(gplot) | |
dev.off() | |
png(file = paste(filename, '_.png', sep=""), width = width * 100, height = height * 100) | |
print(gplot) | |
dev.off() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment