dmurdoch/rgl

rgl does not draw lines with lines3d

uwemenzel opened this issue · 6 comments

Hi,
thank you for providing rgl.
I'm having a small issue using lines3d in the package:

library(MASS)
library(rgl)
set.seed(77)
mu <- c(1, 3, 2)   ## means
Sigma <- matrix(c(3.0, 1.5, 1.0, 1.5, 2.0, 0.5, 1.0, 0.5, 1.0),  nrow = 3, byrow = TRUE)  ## covariance matrix
d3 <- mvrnorm(n = 500, mu = mu, Sigma = Sigma)  ## sample
from <- c(1, 3, 2)
to <- c(2, 2, 1)
par3d(windowRect = c(819, 88, 1492, 706))  
plot3d(d3[, 1], d3[, 2], d3[, 3], col = "blue", size = 5, xlab = "x", ylab = "y", zlab = "z", aspect = c(1, 1, 1))
points3d(from[1], from[2], from[3], col = "red", size = 10)
points3d(to[1], to[2], to[3], col = "red", size = 10)
lines3d(c(from[1], to[1]),  c(from[2], to[2]), c(from[3], to[3]), col="red", lwd = 10) 

Everything works except for the last command. What am I missing here? I just do not see a line but I don't get an error message either. Any hint is appreciated.

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

I get a line from your code, so I really don't know. What version of rgl are you using?

If you run rglwidget() at the end, do you get the correct display in your browser?

I use rgl_0.110.2 and MASS_7.3-58.1
It works when I use rglwidget() , i.e. the line is shown on the page that opens in the browser window, not in the separate window that opens after the par3d command.
This is okay for me, thanks a lot for the fast answer!!

That's not the current version of rgl, so you might get better results if you update. You could even try the Github version, though it's not the easiest package to build.

If those don't work, you might want to look at your graphics drivers. This appears to be a problem there, and often video card manufacturers make updates available.

I'm closing this because it seems unlikely to be caused by rgl.