Tom Wenseleers
2015-Jul-14 11:03 UTC
[Rd] Use cairo fallback resolution greater than 72dpi in cairo_pdf and cairo_ps in grDevices
Dear all, In grDevices R functions cairo_pdf and cairo_ps it is mentioned that when transparency (alpha channels) are used in vector output, it will rasterize the PDF or postscript exported graph at a resolution of 72 dpi : https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/cairo.html You can see the problem if you try library(ggplot2) cairo_ps(file = "test.eps",onefile = FALSE) qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width, alpha = I(0.7)) dev.off() as in the output (here zoomed in) the plot symbols are heavily pixelated then, showing it is only using 72 dpi. I was wondering how the fallback resolution could be increased to 600 dpi? In library(RGtk2) there is a command cairoSurfaceSetFallbackResolution, which I think is what is relevant here, but I would not know how to make grDevices use that parameter. Any thoughts? Using postscript() btw also doesn't work, since that doesn't support transparency, and returns the error "semi-transparency is not supported on this device: reported only once per page". I know I can use svg or pdf instead and that this would solve the problem, but problem is the journal (PloS) I would like to submit to only accepts EPS. So is there any solution to increase the quality in EPS, without having to rasterize everything to PNG? best regards, Tom Wenseleers [[alternative HTML version deleted]]
Prof Brian Ripley
2015-Jul-18 08:09 UTC
[Rd] Use cairo fallback resolution greater than 72dpi in cairo_pdf and cairo_ps in grDevices
The 'at a minimum' information requested by the posting guide is missing. According to their documentation the cairo default fallback resolution is now 300dpi, and when I run your example on Fedora 21 that is what the emitted postscript says it is. You can easily alter the R code to set it to something different: see http://cairographics.org/manual/cairo-cairo-surface-t.html for the call you would need to add. However, I would suggest that you generate a bitmap directly and use that, as PostScript does not support semi-transparency. On 14/07/2015 12:03, Tom Wenseleers wrote:> Dear all, > In grDevices R functions cairo_pdf and cairo_ps it is mentioned that when transparency (alpha channels) are used in vector output, it will rasterize the PDF or postscript exported graph at a resolution of 72 dpi : https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/cairo.html > > You can see the problem if you try > > library(ggplot2) > cairo_ps(file = "test.eps",onefile = FALSE) > qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width, alpha = I(0.7)) > dev.off() > > as in the output (here zoomed in) the plot symbols are heavily pixelated then, showing it is only using 72 dpi. > > I was wondering how the fallback resolution could be increased to 600 dpi? In library(RGtk2) there is a command cairoSurfaceSetFallbackResolution, which I think is what is relevant here, but I would not know how to make grDevices use that parameter. Any thoughts? > > Using postscript() btw also doesn't work, since that doesn't support transparency, and returns the error "semi-transparency is not supported on this device: reported only once per page". > > > I know I can use svg or pdf instead and that this would solve the problem, but problem is the journal (PloS) I would like to submit to only accepts EPS. So is there any solution to increase the quality in EPS, without having to rasterize everything to PNG? > > best regards, > Tom Wenseleers > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK
Prof Brian Ripley
2015-Jul-19 08:33 UTC
[Rd] Use cairo fallback resolution greater than 72dpi in cairo_pdf and cairo_ps in grDevices
On 18/07/2015 09:09, Prof Brian Ripley wrote:> The 'at a minimum' information requested by the posting guide is missing. > > According to their documentation the cairo default fallback resolution > is now 300dpi, and when I run your example on Fedora 21 that is what the > emitted postscript says it is. > > You can easily alter the R code to set it to something different: see > http://cairographics.org/manual/cairo-cairo-surface-t.html for the call > you would need to add.I've added the ability to set the fallback resolution in R-devel, mainly because it seems to be system-specific (I still recommend using a bitmap format such as PNG directly).> > However, I would suggest that you generate a bitmap directly and use > that, as PostScript does not support semi-transparency. > > On 14/07/2015 12:03, Tom Wenseleers wrote: >> Dear all, >> In grDevices R functions cairo_pdf and cairo_ps it is mentioned that >> when transparency (alpha channels) are used in vector output, it will >> rasterize the PDF or postscript exported graph at a resolution of 72 >> dpi : >> https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/cairo.html >> >> You can see the problem if you try >> >> library(ggplot2) >> cairo_ps(file = "test.eps",onefile = FALSE) >> qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size >> Petal.Width, alpha = I(0.7)) >> dev.off() >> >> as in the output (here zoomed in) the plot symbols are heavily >> pixelated then, showing it is only using 72 dpi. >> >> I was wondering how the fallback resolution could be increased to 600 >> dpi? In library(RGtk2) there is a command >> cairoSurfaceSetFallbackResolution, which I think is what is relevant >> here, but I would not know how to make grDevices use that parameter. >> Any thoughts? >> >> Using postscript() btw also doesn't work, since that doesn't support >> transparency, and returns the error "semi-transparency is not >> supported on this device: reported only once per page". >> >> >> I know I can use svg or pdf instead and that this would solve the >> problem, but problem is the journal (PloS) I would like to submit to >> only accepts EPS. So is there any solution to increase the quality in >> EPS, without having to rasterize everything to PNG? >> >> best regards, >> Tom Wenseleers >> >> >> >> >> >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-devel at r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK
Possibly Parallel Threads
- Use cairo fallback resolution greater than 72dpi in cairo_pdf and cairo_ps in grDevices
- Sweave, cairo_pdf, CJK, ghostscript
- patch to add cairo support to Sweave (Re: Sweave, cairo_pdf, CJK, ghostscript)
- Support for high DPI 4K screens
- Default location where packages are stored under Windows