Hello guys,
How to control the dpi of export plots in pdf, eps, png ggplot ?
I mean I need 600 dpi in eps, pdf or png.
Please let me know any suggestions if any.
Regards,
Serdar
ExportPlot <- function(gplot, filename, width=7, height=7) {
# 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()
}
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You can reduce the .tiff file size using the compression arguments. Many journals require .tiff images to be LZW compressed.
Here is a reproducible example using the compression argument:
# CREATE EXAMPLE PLOT
library(ggplot2) # graphics library
data(iris) # Load data
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
p
# SAVE AS HIGH RESOLUTION RASTER (.tiff)
# Can be embeded in Word or saved as standalone file
ggsave("iris.tiff",
p,
units="in",
width=3.25, #1 column
height=3.25,
dpi=1200, # ES&T. 300-600 at PLOS One,
compression = "lzw", # PLOS One 44MB w/out compression, 221KB w/compression
family="Arial") # ggplot default. Could set to others depending on journal
From: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com]
On Behalf Of Serdar Neslihanoglu
Sent: Monday, October 19, 2015 3:26 PM
To: Doug Mitarotonda <dougmit...@gmail.com>
Cc: Brandon Hurr <brando...@gmail.com>; ggplot2 <ggp...@googlegroups.com>
Subject: Re: how to manage dpi 600 or 700 ?
I understood that ı could not manage dpi for eps and ggplot ignore the dpi for eps. I do not understand why always journal ask me dpi of eps ? Try tiff instead of eps, but file size is too large :(
compression | the type of compression to be used. Ignored for |
Hmm, everything worked as expected on my machine using Felix’s data. The compressed image is 137KB and the uncompressed is 43.5MB.
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.4.3 ggplot2_1.0.1 sp_1.2-0
loaded via a namespace (and not attached):
[1] assertthat_0.1 colorspace_1.2-6 DBI_0.3.1 digest_0.6.8 grid_3.1.2 gtable_0.1.2
[7] labeling_0.3 lattice_0.20-29 magrittr_1.5 MASS_7.3-35 munsell_0.4.2 parallel_3.1.2
[13] plyr_1.8.3 proto_0.3-10 R6_2.1.1 Rcpp_0.12.1 reshape2_1.4.1 scales_0.3.0
[19] stringi_0.5-5 stringr_1.0.0 tools_3.1.2
# This next chunk is used for PLOS ONE. Suppresed here to avoid the tiff files |
#opts_chunk$set(tidy = TRUE, cache = FALSE, echo = FALSE, include = FALSE, |
# fig.path = 'figures/', dev = c("pdf", "tiff"), dpi = c(300, 300), |
# dev.args = list(tiff = list(compression = "lzw")), |
# fig.width = 7, fig.height = 7) # default figure size is 7 x 7 inches |