[R] Sweave and ggplot2

Julien Barnier jbarnier at ens-lsh.fr
Mon Sep 24 11:38:28 CEST 2007


Hi,

I am trying to use ggplot2 graphics with Sweave, but I got problems
with transparency support when generating pdf figures, even if I
specify a «pdf.version» argument in Sweave options.


More precisely, forcing the pdf version by creating the file manually
works :

<<fig=FALSE,results=HIDE>>=
pdf(version="1.4",file="foo.pdf")
ggplot(d,aes(y=t,x=u)) + geom_point(colour=alpha('black', 0.05))
dev.off()
@ 
\includegraphics{foo.pdf}


Using the pdf.version argument without using ggplot works, too :

\SweaveOpts{echo=FALSE,pdf.version=1.4}
<<fig=TRUE>>=
plot(t,u,col=rgb(0,0,0,0.1))
@ 


But the following doesn't work (and this is what I would like to do) :

\SweaveOpts{echo=FALSE,pdf.version=1.4}
<<fig=TRUE>>=
ggplot(d,aes(y=t,x=u)) + geom_point(colour=alpha('black', 0.05))
@ 


Does anyone have an idea about this ?

Thanks in advance,

Julien

-- 
Julien Barnier
Groupe de recherche sur la socialisation
ENS-LSH - Lyon, France



More information about the R-help mailing list