Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Right, so I'm using ggplot2 in R to create a graph that involves transparencies (no way around it I'm afraid).

In Latex I use latex - dvips - ps2pdf to compile, because I also need psfrag (and pstricks) and as far as I'm aware, that is the only way to do it. So I need to export the graph from R in an .eps file, right?

So then I get to the problem of dev.copy2eps not supporting transparencies. But I can get around this using cairo_ps, which gets the transparencies to work, but unfortunately now psfrag no longer works...

Any ideas how to get around this?

Minimal example - plots in R:

df <- data.frame(xmin=c(0,0.5), xmax=c(1,1.5), ymin=c(0,0.5), ymax=c(1,1.5))

p <- ggplot() + 
  scale_x_continuous(name="x") + 
  scale_y_continuous(name="y") +
  geom_rect(data=df, mapping=aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax), color="black", alpha=0.5)

cairo_ps(file='cairo.eps', width=5, height=5)

X11(width=5, height=5)

Minimal example - LaTex ( LaTex + dvips + ps2pdf + view pdf):



\psfrag{x}{X axis}
\psfrag{y}{Y axis}


And here's what I get:

transparency works on left, psfrag works on right

Edit: Christoph is right, it works correctly for me on two different Ubuntu machines. The problem occurs on a Windows 7, also with R 3.0.2 running. I guess migrating the topic to the LaTex forum wasn't such a good idea after all. Can it be moved back?


migration rejected from Feb 28 '14 at 19:27

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Stefan Kottwitz Feb 28 '14 at 19:27

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Cool, thanks Werner, and sorry for not doing that in the first place! – maja Feb 26 '14 at 22:51
For me it works with R version 3.0.2 on Debian: – Christoph Feb 27 '14 at 9:40
Thanks Christoph, edited and requested migration back! – maja Feb 27 '14 at 11:49
try the tikzDevice, it can be a pain to install, but once it works it's pretty sweet – baptiste Feb 27 '14 at 12:33
maja: Your original question is still there at StackOverflow, you need to (let it) reopen there. – Stefan Kottwitz Feb 28 '14 at 15:51

Browse other questions tagged or ask your own question.