[R] Separate point sizes in rgl.points()?

Duncan Murdoch murdoch.duncan at gmail.com
Sat Aug 29 13:21:21 CEST 2015


On 28/08/2015 4:00 PM, Atte Tenkanen wrote:
> Hi,
> 
> DrawDensity3D-function in package VecStatGraphs3D utilizes 
> rgl.points-function {rgl}:

You shouldn't be using rgl.points.  Use points3d.

The pointsize is a material property (see ?material3d), and isn't a
vector, so you only get one size per call to points3d.

Duncan Murdoch

> 
> function (vectors, Div = 40, Layers = 3, DrawAxes = FALSE)
> {
>      open3d(windowRect = c(100, 100, 800, 800))
>      bg3d("white")
>      Cx = vectors[, 1]
>      Cy = vectors[, 2]
>      Cz = vectors[, 3]
>      Cr <- kde3d(x = Cx, y = Cy, z = Cz, n = Div)
>      th <- seq(min(Cr$d), max(Cr$d), len = Layers + 2)
>      ramp <- colorRamp(c("white", "yellow", "red"))
>      colo <- rgb(ramp(seq(0, 1, length = Layers)), maxColorValue = 255)
>      al <- seq(0.1, 0.6, len = Layers)
>      module = sqrt(Cx * Cx + Cy * Cy + Cz * Cz)
>      spheres3d(0, 0, 0, radius = max(module), color = "black",
>          front = "line", back = "line", lwd = 1, smooth = TRUE,
>          lit = TRUE, line_antialias = FALSE, alpha = 0.2)
>      x <- c(0, max(module), 0, 0)
>      y <- c(0, 0, max(module), 0)
>      z <- c(0, 0, 0, max(module))
>      labels <- c("", "X", "Y", "Z")
>      i <- c(1, 2, 1, 3, 1, 4)
>      text3d(x, y, z, labels, adj = 0.8, cex = 1.5, font = 2, color = 
> "black")
>      segments3d(x[i], y[i], z[i], lwd = 3)
>      rgl.points(x = Cx, y = Cy, z = Cz, size = 3, color = "black")
>      contour3d(Cr$d, level = th[c(-1, -(Layers + 2))], x = Cr$x,
>          y = Cr$y, z = Cr$z, alpha = al, color = colo, add = TRUE,
>          engine = "rgl", fill = TRUE, smooth = 2, material = "shiny")
>      if (DrawAxes == TRUE) {
>          axes3d()
>      }
> }
> 
> Is it somehow possible to define the sizes of the points all separately?
> 
> I tried by adding ”Psize” to function arguments and changing
> 
> rgl.points(x = Cx, y = Cy, z = Cz, size = Psize, color = "black”),
> 
> then giving individual point size to each point but this does not work.
> 
> This does’t work either:
> 
> for(i in 1:length(Cx))
> {
>      rgl.points(x=Cx[i], y=Cz[i], z=Cz[i], size=PSize[i], col= Colors[i])
> }
> 
> Atte Tenkanen
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



More information about the R-help mailing list