[Rd] PDFs and SVGs containing rasterGrobs don't display correctly in some other software
Richard Cotton
richierocks at gmail.com
Thu Nov 5 12:43:56 CET 2015
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?
--
Regards,
Richie
Learning R
4dpiecharts.com
More information about the R-devel
mailing list