[R] rgl.postscript
    Duncan Murdoch 
    murdoch at stats.uwo.ca
       
    Tue May 29 21:10:18 CEST 2007
    
    
  
On 5/29/2007 1:53 PM, coar wrote:
> Hi, 
> I am having an issue when creating a postscript file from RGL window.  It 
> seems to cut off some of the axis labels.  Here is the code I am using.
> 
> I created a 3D plot using RGL_0.71 with R 2.5 on Windows XP.
> 
> z1<-c(5,4,1,4.5,2,3,2,1,1)
> z2<-c(6,8,7,7.5,5,3.5,4,1,1)
> z3<-c(3,2,4,7,3,4.5,6,2,3)
> x1<-seq(1,9)
> x2<-seq(1,9)
> x3<-seq(10,18)
> 
> y1<-seq(8,0)
> y2<--1*y1
> y3<-rep(0,9)
> m1<-cbind(x1,y1,z1)
> m2<-cbind(x2,y2,z2)
> m3<-cbind(x3,y3,z3)
> m3<-rbind(m2[9,],m3)
> 
> up1<-m1[,-2]
> up2<-m2[,-2]
> 
> lp<-m3[,-2]
> p1<-rbind(up1, lp[-1,])
> p2<-rbind(up2, lp[-1,])
> sp1<-spline(p1)
> sp2<-spline(p2)
> 
> sp1m<-cbind(sp1$x,sp1$y)
> sp2m<-cbind(sp2$x,sp2$y)
> 
> ge9<-(sp1$x>=9)
> ge9recs<-seq(1,length(ge9))[ge9]
> 
> b1<-sp1m[ge9recs,]
> b2<-sp2m[ge9recs,]
> 
> b1b2<-cbind(b1[,2],b2[,2])
> 
> bavg<-apply(b1b2,1,mean)
> blow<-cbind(sp1m[ge9recs,1],bavg)
> 
> path.one<-rbind(sp1m[-ge9recs,],blow)
> path.two<-rbind(sp2m[-ge9recs,],blow)
> 
> uy1<-9-path.one[-ge9recs,1]
> ly1<-rep(0,length(ge9recs))
> y1<-c(uy1,ly1)
> 
> uy2<--1*(9-path.two[-ge9recs,1])
> ly2<-rep(0,length(ge9recs))
> y2<-c(uy2,ly2)
> 
> m1<-cbind(path.one,y1)
> m2<-cbind(path.two,y2)
> d.mat<-rbind(m1,m2)
> 
> open3d()
> 
> points3d(x=d.mat[,1],y=d.mat[,3],z=d.mat[,2],size=3)
> lines3d(x=m1[,1],y=m1[,3],z=m1[,2],size=3)
> lines3d(x=m2[,1],y=m2[,3],z=m2[,2],size=3)
> 
> I then added axes using
> 
> box3d()
> axes3d(c('x--'),tick=TRUE,nticks=5) 
> axes3d(c('z--'),tick=TRUE,nticks=5) 
> axes3d(c('z++'),tick=TRUE,nticks=5)
> 
> title3d(main = "Test 3-D plot", sub = NULL, xlab ="Lag", ylab = NULL, zlab = 
> "Dissolved O2", line = NA)
> 
> 
> I did some rotation to determine a nicer view of the plot.  I now wanted to 
> create a snapshot of the plot (using rgl.postscript since I will be using in 
> LATEX).  However, it cuts off some of the axis labels.  Is there a way to 
> adjust the area that gets captured to the postscript file?  or some other way 
> to fix this?
You could try resizing, or using Latex to put the labels on the plot, 
but there is no parameter to control what gets cut off.  You should also 
be aware that the Postscript support is somewhat limited, and you might 
be better off using a bitmap copy with rgl.snapshot.
Duncan Murdoch
    
    
More information about the R-help
mailing list