[R] placement of plot in rgl

Duncan Mackay du|c@|m@ @end|ng |rom b|gpond@com
Tue Jul 2 03:21:26 CEST 2019


Dear All

I rarely use the excellent rgl package but have sometimes run into a problem
with placement of the plot within the window.
Up to now I have avoided having to find a solution.

I was going through the series of posts from 
https://stat.ethz.ch/pipermail/r-help/2019-June/463014.html  
when I came across
https://stat.ethz.ch/pipermail/r-help/2019-June/463057.html
where the plot starts in the bottom left corner as a results when moving it
parts of the plot get obscured.

Is there a way around this; forceClipregion and  getr3dDefaults() to me seem
a little sparse on details.
I tried using xyz.coords but no improvement

Code is as follows:

p1 <-
structure(c(0.6, 0.584775906502257, 0.54142135623731, 0.476536686473018, 
0.4, 0.323463313526982, 0.258578643762691, 0.215224093497743, 
0.2, 0.215224093497743, 0.25857864376269, 0.323463313526982, 
0.4, 0.476536686473018, 0.541421356237309, 0.584775906502257, 
0.4, 0.476536686473018, 0.54142135623731, 0.584775906502257, 
0.6, 0.584775906502257, 0.54142135623731, 0.476536686473018, 
0.4, 0.323463313526982, 0.258578643762691, 0.215224093497743, 
0.2, 0.215224093497743, 0.25857864376269, 0.323463313526982, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), .Dim = c(16L, 
3L), .Dimnames = list(NULL, c("x1", "y1", "z1")))

p2 <-
structure(c(0.7, 0.684775906502257, 0.64142135623731, 0.576536686473018, 
0.5, 0.423463313526982, 0.35857864376269, 0.315224093497743, 
0.3, 0.315224093497743, 0.35857864376269, 0.423463313526982, 
0.5, 0.576536686473018, 0.641421356237309, 0.684775906502257, 
0.5, 0.576536686473018, 0.641421356237309, 0.684775906502257, 
0.7, 0.684775906502257, 0.64142135623731, 0.576536686473018, 
0.5, 0.423463313526982, 0.35857864376269, 0.315224093497743, 
0.3, 0.315224093497743, 0.35857864376269, 0.423463313526982, 
0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 
0.5, 0.5, 0.5), .Dim = c(16L, 3L), .Dimnames = list(NULL, c("x2", 
"y2", "z2")))

p3 <-
structure(c(0.4, 0.392387953251129, 0.370710678118655, 0.338268343236509, 
0.3, 0.261731656763491, 0.229289321881345, 0.207612046748871, 
0.2, 0.207612046748871, 0.229289321881345, 0.261731656763491, 
0.3, 0.338268343236509, 0.370710678118655, 0.392387953251129, 
0.3, 0.338268343236509, 0.370710678118655, 0.392387953251129, 
0.4, 0.392387953251129, 0.370710678118655, 0.338268343236509, 
0.3, 0.261731656763491, 0.229289321881345, 0.207612046748871, 
0.2, 0.207612046748871, 0.229289321881345, 0.261731656763491, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), .Dim = c(16L, 
3L), .Dimnames = list(NULL, c("x3", "y3", "z3")))

library(rgl)

open3d()

plot3d(p1,
       box = FALSE,
       axes = FALSE,
       xlim = c(0,1),
       ylim = c(0,1),
       zlim = c(0,1),
       xlab = "",
       ylab = "",
       zlab = "",
       type = "n")

points3d(p1, size = 10, col = "red")
points3d(p2, size = 10, col = "blue")
points3d(p3, size = 10, col = "green")

axes3d(c('x', 'y', 'z'))

title3d(xlab = "x", ylab = "y", zlab = "z", line = 1.7)

aspect3d(1,1,1)               

highlevel()

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351



More information about the R-help mailing list