rgl.postscript() failure when saving a scene

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rgl.postscript() failure when saving a scene

ppiras
Dear all,

I write to the community to know if other people
expierenced the same problem. I want to save a rgl
scene where I plotted a 3d cloud of spheres whose
radius is set proportional to a given variable and
coloured by another group variable and with 95%
ellipsoids for distribution of any group.
I had no problem at all for coding but I had two
problem when saving the scene (in any format) using
rgl.postscript()
1-  using plot3d(), if the points are set to sphere
whose radius is proportional to a given variable the
rgl.postscript() causes R crash

2- using simple points the scene is saved but the
transaprencies of ellipsoids are lost.

HERE below I copy a script with simulated data. I use
R.2.14 but even with R2.12 I got the same problems
Thankyou in advance for your help.


datii<-data.frame(cbind(rnorm(30,1,1),rnorm(30,2,1),rnorm(30,3,1),abs(rnorm(30,4,1)),c(rep(1:2,15))))

axis3D(axis.col="black",axis.scale=max(datii[,1:3]),axis.len=0.03)
arrows3D(c(0,0,0),c(-max(datii[,1:3]),0,0),length=0.03)
arrows3D(c(0,0,0),c(0,-max(datii[,1:3]),0),length=0.03)
arrows3D(c(0,0,0),c(0,0,-max(datii[,1:3])),length=0.03)


#########  with this command, i.e. "type="p", I cannot
set the points dimension proportional to a given
variable #######
plot3d(datii[,1:3],box=F,col=datii[,5],type="p",cex=datii[,4]/10,add=T,bbox=F)


##### MAJOR PROBLEM: here (type="s") I can do that
but...when I go to save the scene using
rgl.postscript() R crasches .###########
plot3d(datii[,1:3],box=F,col=datii[,5],type="s",radius=datii[,4]/10,add=T,bbox=F)



#### MINOR PROBLEM: these are the 95% ellipses for any
group; when saving using rgl.postscript() IN ANY
FORMAT the transaparencies are lost ####
plot3d(ellipse3d(cov(subset(datii[,1:3],datii[,5]==1)),centre=c(mean(subset(datii[,1],datii[,5]==1)),mean(subset(datii[,2],datii[,5]==1)),mean(subset(datii[,3],datii[,5]==1)))),col=1,alpha=0.3,add=T)
plot3d(ellipse3d(cov(subset(datii[,1:3],datii[,5]==2)),centre=c(mean(subset(datii[,1],datii[,5]==2)),mean(subset(datii[,2],datii[,5]==2)),mean(subset(datii[,3],datii[,5]==2)))),col=2,alpha=0.3,add=T)

rgl.postscript(file="test.pdf",fmt="pdf") #### THIS
COMMAND CAUSES R CRASCH WHEN THE RGL SECENE IS LOADED
WITH POINTS SET AS "SPHERES"  ###  AND THEIR  RADIUS
IS PROPORTIONAL TO A GIVEN VARIABLE.








--
Paolo Piras
Center for Evolutionary Ecology
             and
Dipartimento di Scienze Geologiche, Università Roma Tre
Largo San Leonardo Murialdo, 1, 00146 Roma
Tel: +390657338000
email: [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: rgl.postscript() failure when saving a scene

Duncan Murdoch-2
On 09/12/2011 9:49 AM, [hidden email] wrote:

> Dear all,
>
> I write to the community to know if other people
> expierenced the same problem. I want to save a rgl
> scene where I plotted a 3d cloud of spheres whose
> radius is set proportional to a given variable and
> coloured by another group variable and with 95%
> ellipsoids for distribution of any group.
> I had no problem at all for coding but I had two
> problem when saving the scene (in any format) using
> rgl.postscript()
> 1-  using plot3d(), if the points are set to sphere
> whose radius is proportional to a given variable the
> rgl.postscript() causes R crash
>
> 2- using simple points the scene is saved but the
> transaprencies of ellipsoids are lost.
>
> HERE below I copy a script with simulated data. I use
> R.2.14 but even with R2.12 I got the same problems
> Thankyou in advance for your help.
>
>
> datii<-data.frame(cbind(rnorm(30,1,1),rnorm(30,2,1),rnorm(30,3,1),abs(rnorm(30,4,1)),c(rep(1:2,15))))
>
> axis3D(axis.col="black",axis.scale=max(datii[,1:3]),axis.len=0.03)
> arrows3D(c(0,0,0),c(-max(datii[,1:3]),0,0),length=0.03)
> arrows3D(c(0,0,0),c(0,-max(datii[,1:3]),0),length=0.03)
> arrows3D(c(0,0,0),c(0,0,-max(datii[,1:3])),length=0.03)
>
>
> #########  with this command, i.e. "type="p", I cannot
> set the points dimension proportional to a given
> variable #######
> plot3d(datii[,1:3],box=F,col=datii[,5],type="p",cex=datii[,4]/10,add=T,bbox=F)
>
>
> ##### MAJOR PROBLEM: here (type="s") I can do that
> but...when I go to save the scene using
> rgl.postscript() R crasches .###########
> plot3d(datii[,1:3],box=F,col=datii[,5],type="s",radius=datii[,4]/10,add=T,bbox=F)
>
>
>
> #### MINOR PROBLEM: these are the 95% ellipses for any
> group; when saving using rgl.postscript() IN ANY
> FORMAT the transaparencies are lost ####
> plot3d(ellipse3d(cov(subset(datii[,1:3],datii[,5]==1)),centre=c(mean(subset(datii[,1],datii[,5]==1)),mean(subset(datii[,2],datii[,5]==1)),mean(subset(datii[,3],datii[,5]==1)))),col=1,alpha=0.3,add=T)
> plot3d(ellipse3d(cov(subset(datii[,1:3],datii[,5]==2)),centre=c(mean(subset(datii[,1],datii[,5]==2)),mean(subset(datii[,2],datii[,5]==2)),mean(subset(datii[,3],datii[,5]==2)))),col=2,alpha=0.3,add=T)
>
> rgl.postscript(file="test.pdf",fmt="pdf") #### THIS

I'd suggest using rgl.snapshot instead.  As the documentation says,
rgl.postscript doesn't always work.  You could also try a newer version
of the gl2ps library that rgl uses for Postscript conversions.

Duncan Murdoch

> COMMAND CAUSES R CRASCH WHEN THE RGL SECENE IS LOADED
> WITH POINTS SET AS "SPHERES"  ###  AND THEIR  RADIUS
> IS PROPORTIONAL TO A GIVEN VARIABLE.
>
>
>
>
>
>
>
>

______________________________________________
[hidden email] 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.