[R] Tutorial on rgl Graphics

David Winsemius dwinsemius at comcast.net
Tue May 25 02:17:01 CEST 2010


On May 24, 2010, at 2:36 PM, vincent.deluard wrote:

>
>
> Hi Duncan,
>
> I love your plotlm3d function!
>
> I want to plot the following data:
>
>> x
> [1]  1  2  3  4  5  6  7  8  9 10
>> y
> [1] 0.5678042 0.3986702 0.3063544 0.2554426 0.1954868 0.1238850  
> 0.1161249
> 0.1689951 0.1826783 0.2406300
>> z
> [1] 0.2558812 0.2619668 0.2585930 0.2563669 0.2588323 0.2734029  
> 0.2770458
> 0.2782657 0.2850179 0.3015296
>
> Then i execute:
>
> open3d()
> plotlm3d(x, y, z,
>         surface = T,
>         model   = 'z ~ x + y',
>         xlab    = 'x',
>         ylab    = 'y'
> )
>
> The chart is beautiful but I would like to change the scale on the z- 
> axis
> to:
> seq(0.25,0.31,0.01))
>
> I tried this command:
> axis(3, at=seq(0.25,0.34,0.01))
>

Not too surprisingly, since it is not an rgl function.

?axis3d

> But it not work - my guess is that the underlying function plotlm3d  
> needs to
> modified but I cannot figure where.

You need to use an axis function appropriate to the particular  
graphics device. This is the axis code inside the plotlm3d  function:

   if(simple.axes) {
      axes3d(c('x', 'y', 'z'))
      title3d(xlab = xlab, ylab = ylab, zlab = zlab)
    }
    else
      decorate3d(xlab = xlab, ylab = ylab, zlab = zlab, box = box)

Try taking the "z" out to the axes3d call and then using:

axis3d("z", zat=seq(0.25,0.34,0.01) )

I'm attaching a tiff screen grab (which won't make it to the list)  
because I do not know how to save the current state of the x11 window  
as a pdf.
-------------- next part --------------
You may also want to look at:

?bbox3d

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list