Dear Duncan,

thanks for your quick response. 
Below is my second trial. I had to use mtext3d to place the label for the 
z-axis 
at the new axis where the ticks are drawn (if there's a simpler solution, please
let me know). Was the usage of rgl.viewpoint meant this way? It is nice to 
adjust the rotation of the plotted object by hand but then I want to make sure
the subsequent plot(s) have precisely the same rotation. 

Okay, great. 

One more thing I am wondering is: I tried to pass through arguments like
marklen or expand to rgl.bbox/bbox3d. Is anything like this possible? I would 
like
to change the length of the axis ticks.

Cheers & many thanks,

Marius

PS: I read somewhere that plotmath-expressions are not available in rgl. Is 
there
an update on this? I know it may be very difficult to implement this, I'm just 
wondering if there is an update/workaround on this (?)

require(rgl)
s <- seq(0, 1, length.out=21)
M <- function(u) apply(u, 1, min)
u <- s
v <- s
z <- outer(u, v, function(u,v) M(cbind(u,v)))
persp3d(u, v, z, aspect="iso", front="line", lit=FALSE, axes=FALSE, xlab="", 
        ylab="", zlab="") 
axes3d(edges=c('x--','y--','z+-')) # label the right axes
title3d(xlab="x", ylab="y", zlab="") # put in axes labels [z is wrong]
mtext3d("z", edge='z+-', line=2) # put in z-axis label by hand
par3d(windowRect=c(0,0,480,480), zoom=1.2) # use zoom to get everything on the 
viewport; then adjust rotation by hand
pl <- par3d(c("userMatrix", "zoom", "FOV")) # record for use in other plots
rgl.postscript("myplot.pdf", fmt="pdf") # print to file
rgl.viewpoint(zoom=pl$zoom, fov=pl$FOV, userMatrix=pl$userMatrix, 
interactive=FALSE) # set the viewpoint for the next plot to make sure it looks 
the same

On 2011-09-09, at 12:41 , Duncan Murdoch wrote:

> On 11-09-09 6:18 AM, Marius Hofert wrote:
>> Dear expeRts,
>> 
>> I am a new user of rgl, below is my first trial to plot a simple function in 
>> 3d.
>> I managed to put the axes in the right locations, but:
>> (1) The xlab, ylab, and zlab arguments are ignored; how can I put in axes 
>> labels?
> 
> Those are documented on the axes3d page, but are arguments to title3d, not 
> axes3d.  So add title3d(xlab="x", etc.
> 
>> (2) Since I removed the axes in persp3d() the viewport is too small; is it 
>> possible
>>     to keep the size of the viewport?
> 
> You can manually adjust it to your taste, then write down the value of 
> par3d("zoom").  Later you can reproduce the resizing by calling par3d(zoom= 
> <saved value> ).
> 
> 
>> (3) The box is not correctly drawn, there are two "holes", one in (0,0,1) 
>> and one
>>     in (1,1,0); how can I fix that?
> 
> That happens because OpenGL has a limit on the range of depths that can be 
> displayed, and the corners of the box have been adjusted to be too close or 
> far.  This is arguably a bug in rgl, but it's sometimes a feature.
> 
> What I'd suggest is that you don't use rgl.viewpoint, you just manually 
> adjust the display as you like, without making it quite as extreme, then 
> record the values of par3d(c("userMatrix", "zoom", "FOV")); those control the 
> viewpoint.
> 
> Duncan Murdoch
> 
>> 
>> Cheers,
>> 
>> Marius
>> 
>> 
>> require(rgl)
>> s<- seq(0, 1, length.out=21)
>> M<- function(u) apply(u, 1, min)
>> u<- s
>> v<- s
>> z<- outer(u, v, function(u,v) M(cbind(u,v)))
>> persp3d(u, v, z, aspect="iso", front="line", lit=FALSE, axes=FALSE, xlab="",
>>         ylab="", zlab="")
>> axes3d(edges=c('x--','y--','z+-'), xlab="x", ylab="y", zlab="z")
>> par3d(windowRect=c(0,0,480,480))
>> 
>> R1<- rotationMatrix(-55*pi/180, 1,0,0)
>> R3<- rotationMatrix(50*pi/180, 0,0,1)
>> R<- R1 %*% R3
>> rgl.viewpoint(interactive=TRUE, userMatrix=R) # rotate
>> rgl.postscript("myplot.pdf", fmt="pdf")
>> ______________________________________________
>> R-help@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.
> 

______________________________________________
R-help@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.

Reply via email to