[R] 3D-scatterplots - high quality rendering?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Oct 21 20:04:53 CEST 2010


On 21/10/2010 1:23 PM, J.delasHeras at ed.ac.uk wrote:
> Quoting Duncan Murdoch<murdoch.duncan at gmail.com>:
>
> >  J.delasHeras at ed.ac.uk wrote:
> >>  I have just started using the package 'rgl' to explore my data as a
> >>   3D scatterplot.
> >>
> >>  It's a great tool. But I would like to be able to save some graph
> >>  views and it appears the only format available is 'png' and it
> >>  doesn't look that nice. It is excellent to work with on screen and
> >>   explore/play, but when it comes to producing a good quality
> >>  graphic   I'm a bit disappointed.
> >>
> >>  So the questions I have are:
> >>
> >>  1) is there a way to render the graph in the RGL device as a high
> >>  quality graphic?
> >>
> >
> >  You can use rgl.postscript for various other formats, but you may find
> >  the bitmap output is better.  In particular, shading is not always done
> >  correctly.
> >
> >  Duncan Murdoch
>
>
> Hi Duncan,
>
> thanks for that.
> Stupidly I hadn't realised only part of the manual had printed so I
> was missing a lot of interesting options, not only this one but others
> to animate views.
>
> The type of plots I'm producing are similar to these:
>
> library(rgl)
> m<-matrix(rnorm(900),ncol=3)
> plot3d(m,col=rainbow(6),type="s",size=0.8)
>
> I tried rgl.postscript to save to pdf, as it's become my default
> format when I want smooth plots using standard R graphics X11()
> It looks smoother, but I get some "artifacts" in that the edges and
> colouring of a number of spheres are rough, or incompletely coloured
> (imagine a small scratch on a photograph)
>
> using 'rgl.snapshot' to output a bitmap (png) with small spheres it
> doesn't look that great. The default squares look fine 'though.

The way I usually save output is to use rgl.snapshot after increasing 
the size of the window as large as possible.  At 1000 x 1000 pixels I 
find the output okay.

How large is possible will depend on your hardware and OpenGL driver.  
Usually you can't make it any bigger than your physical monitor, and you 
can't always make it that big.

Duncan Murdoch
> I guess I'll just play with these limitations. I was just wondering if
> there was a simple way to get significantly better results.
> But I'm not complaining! :) the 'rgl' package is pretty impressive!
>
> Thank you.
>
> Jose de las Heras
>
>
>
>
>
>



More information about the R-help mailing list