[R] rgl.Sweave not producing transparency in pdf plots with alpha
Duncan Murdoch
murdoch.duncan at gmail.com
Wed May 2 18:26:02 CEST 2012
On 02/05/2012 11:00 AM, Alexander Shenkin wrote:
> Hi Folks,
>
> I'm trying to get rgl.Sweave to produce plots with transparency.
> However, it just seems to produce opaque plots when pdf is the output
> type. Perhaps this is a known issue? I'll just use .png in the
> meantime, but wanted to see about this, as I didn't see it in the
> documentation (though it's possible I missed it).
That uses the rgl.postscript() function, which uses the GL2PS library to
convert to PDF. It may be that it doesn't support transparency in your
scene. Or perhaps it just hasn't been turned on: GL2PS didn't support
transparency when rgl.postscript was written.
Duncan Murdoch
>
> Thanks,
> Allie
>
>
>
>
> \documentclass{article}
> \title {rgl test}
> \usepackage{Sweave}
> \begin {document}
>
> This is a test of rgl.sweave's alpha capability.
>
> \begin{figure}
> % uncomment line below for png output (correct transparency)
> %<<echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
> resolution=100>>=
> <<echo=FALSE, grdevice=rgl.Sweave, fig=TRUE, width=5, height=5,
> resolution=100, outputtype=pdf, pdf=TRUE>>=
> library(rgl)
> data(volcano)
> z<- 2 * volcano # Exaggerate the relief
> x<- 10 * (1:nrow(z)) # 10 meter spacing (S to N)
> y<- 10 * (1:ncol(z)) # 10 meter spacing (E to W)
> zlim<- range(y)
> zlen<- zlim[2] - zlim[1] + 1
> colorlut<- terrain.colors(zlen) # height color lookup table
> col<- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point
> #open3d()
> surface3d(x, y, z, color=col, back="lines", alpha=0.75)
> @
> \end{figure}
>
> \end{document}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list