# Re: [R] symbol() function in 3d

From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>
Date: Wed 08 Feb 2006 - 04:21:35 EST

On Tue, 2006-02-07 at 16:23 +0000, Laura Quinn wrote:
> Hello,
>
> I was wondering if there is anything within the 3d rgl library that is
> similar to the symbol() function? I am hoping to overlay a surface3d()
> plot with some circles of varying size/color. I tried using the points3d()
> function, but this only allows me to add circles all of the same size.
>
> Thanks,
> Laura

Hi Laura,

Are spheres OK rather than circles? If so, then will the following work?:

```x <- rnorm(12)
y <- rnorm(12)
z <- rnorm(12)
```

rgl.open()
spheres3d(x,y,z, radius = 1:12 * 0.05, color = colors()[1:12])

the color argument is described in ?rgl.material where unfortunately the size argument can not be a vector our you could have used that with points3d() to achieve what you wanted.

Example with surface from ?surface3d

data(volcano)

```z <- 2 * volcano        # Exaggerate the relief
x <- 10 * (1:nrow(z))   # 10 meter spacing (S to N)
y <- 10 * (1:ncol(z))   # 10 meter spacing (E to W)
```
zlim <- range(y)
zlen <- zlim[2] - zlim[1] + 1
colorlut <- terrain.colors(zlen) # height color lookup table col <- colorlut[ z-zlim[1]+1 ] # assign colors to heights for each point rgl.clear()
surface3d(x, y, z, color=col, back="lines") ## choose some co-ords
samp <- sample(seq(along = y), 20)
## draw the spheres
spheres3d(x[samp], y[samp], z[samp] * 1.75, radius = 1:20 * 2,

color = colors()[samp])

HTH G

>
> Laura Quinn
> Institute of Atmospheric Science
> School of Earth and Environment
> University of Leeds
> Leeds
> LS2 9JT
>
> tel: +44 113 343 1596
> fax: +44 113 343 6716
> mail: laura@env.leeds.ac.uk
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help

```--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help