Take the 2-minute tour ×
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:

library('ggplot2')
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)
p
dev.off()

X11(width=5, height=5)
p
dev.copy2eps(file="regular.eps")

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

\documentclass{minimal}
\usepackage{pstricks}
\usepackage[dvips]{graphicx}
\usepackage{psfrag}

\begin{document}

\begin{pspicture}(\textwidth,10)
\psfrag{x}{X axis}
\psfrag{y}{Y axis}
\rput[l](0,0){\includegraphics[width=0.5\textwidth]{cairo.eps}}
\rput[l](0.5\textwidth,0){\includegraphics[width=0.5\textwidth]{regular.eps}}
\end{pspicture}

\end{document}

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?

share

migration rejected from stackoverflow.com Feb 28 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 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 at 22:51
1  
For me it works with R version 3.0.2 on Debian: i.stack.imgur.com/DAbmG.png –  Christoph Feb 27 at 9:40
    
Thanks Christoph, edited and requested migration back! –  maja Feb 27 at 11:49
    
try the tikzDevice, it can be a pain to install, but once it works it's pretty sweet –  baptiste Feb 27 at 12:33
    
maja: Your original question is still there at StackOverflow, you need to (let it) reopen there. –  Stefan Kottwitz Feb 28 at 15:51

Browse other questions tagged or ask your own question.