tags:

views:

69

answers:

2

I love the plots that ggplot generates. However, it is still somewhat cumbersome to get publication quality plots directly. I usually have to do some post processing in Illustrator (i.e. changing fonts, numbering figures etc). While I could save as tiff or png, eps is best for manipulating figures in Illustrator (I can ungroup objects, move the legend/text etc).

When I save a ggplot object with some transparency (either in points or a smoother) I get this error:

Warning message:
In grid.Call.graphics("L_points", x$x, x$y, x$pch, x$size) :
  semi-transparency is not supported on this device: reported only once per page

Is there a workaround?

+2  A: 

R's eps "device" doesn't support partial transparency, but, if I remember correctly, its PDF device does. Illustrator ought to be able to read PDFs with equal facility to EPSes, or if not, try converting them after generation with pdftops (not pdf2ps, they are totally different programs and pdf2ps's output is ... inferior).

Note that R doesn't try to optimize its PDF output at all, so even if you do get a plot that needs no postproduction, you will want to run it through a compression utility like qpdf at the very least.

Zack
Thanks! For those of you on OSX, <a href="http://tex.aanhet.net/epspdf/#install">here</a> is an easy tool to convert from pdf to eps.
Maiasaura
+3  A: 

You could also try exporting as SVG via the svg device. Not sure if Illustrator can read SVG, but Inkscape can, and it's open source :) I've done some good things with R output to SVG in Inkscape, and the groupings are preserved as with EPS. Can't be 100% sure it handles opacity but I'm sure its in the SVG standard.

Spacedman
SVG works too although it created weird, large, semitransparent letters in the background. There was a really big O,X,Y in the background. But I was able to remove those. So this is another option that allows for skipping the conversion. thanks.
Maiasaura