[Rd] PDFs and SVGs containing rasterGrobs don't display correctly in some other software
Hadley Wickham
h.wickham at gmail.com
Thu Nov 5 14:04:40 CET 2015
On Thu, Nov 5, 2015 at 5:43 AM, Richard Cotton <richierocks at gmail.com> wrote:
> I've just been trying to post-process some R-created heatmaps using
> Inkscape, but I can't get them to display correctly in that software.
>
> To reproduce:
>
> library(grid)
> r <- as.raster(matrix(runif(25), 5, 5))
> pdf("test.pdf")
> grid.newpage()
> grid.raster(r, interpolate = FALSE)
> dev.off()
>
> This figure should be a five by five block of grey squares. This is
> what I see in the R GUI device window, and when I open test.pdf in
> Abode Reader or SumatraPDF.
>
> However, when I open the file in Inkscape or Firefox, each of the
> squares is blurred.
>
> I tried swapping grDevices::pdf for Cairo::CairoPDF and got the same
> result. I also tried generating SVGs using both grDevices::svg and
> Cairo::CairoSVG, and also got the same result.
>
> I see the same thing using R-devel and R3.2.2 under Windows, and (with
> an older version of R) under Linux.
>
> I don't know whether the problem is with grid's rasterGrobs, or how R
> writes PDF and SVG files, or with Inkscape and Firefox's method of
> rendering those files, or with me. Please can you help me narrow it
> down.
>
> - Can you reproduce my problem? That is, when you run the above code,
> does the file look OK in a PDF reader but blurry in Inkscape?
> - Do you know of any issues with using rasterGrobs in PDFs or SVGs?
Yes - many viewers (esp. OS X preview) interpolate them even when the
PDF requests that they shouldn't be. I worked through this with Paul
Murrell a couple of months ago - we're reasonably certain that R is
doing the right thing, it's the renderers that are failing.
Hadley
--
http://had.co.nz/
More information about the R-devel
mailing list