When building images or heat maps in pdf files, as in the example below, they are saved as vector objects, where each pixel in the image or cell in the heat map is represented by a square. Even with modest resolutions, this leads to unnecessarily large files, which also show ugliness on some devices. Is there a way to make R save only the image area as png or jpg embedded in pdf, but save text, axes, annotations, etc. as vector graphics?
I ask because I often print R graphics, sometimes on large posters, and would like to combine the best of the two worlds. Of course, I could save the whole figure like high-resolution png, but that would not be so elegant, or combine it manually, for example. in Inkscape , but it's pretty tedious.
my.func <- function(x, y) x %*% t(y) pdf(file="myPlot.pdf") image(my.func(seq(-10,10,,500), seq(-5,15,,500)), col=heat.colors(100)) dev.off()

Thank you for your time, ideas and, I hope, solutions!
source share