`bbox3d` does not respect `xlen`
Closed this issue · 4 comments
Reprex:
desired_tick_count <- 1
x <- rnorm(100)
y <- rnorm(100)
z <- rnorm(100)
dev.new()
open3d()
points3d(x, y, z)
bbox3d(
xlen=2, ylen=2, zlen=2,
xlab='X', ylab='Y', zlab = 'Z',
color = c("#333377", "black"), emission = "#333377",
specular = "#3333FF", shininess = 5, alpha = 0.8
)
Expected result: a plot with about 1 tick mark on each axes. ("about" because this is a suggestion for pretty.)
Actual result: a plot with 4-6 tick marks per axis.
I suspected this may simply be due to pretty not taking our suggestion, but putting the data into pretty directly, it returns 3 items. So still, I would expect 3 tick marks per axis, not 4-6.
> print(pretty(x))
[1] -3 -2 -1 0 1 2 3
> print(pretty(x, desired_tick_count))
[1] -5 0 5
- rgl Version: 1.3.1, downloaded the tar.gz from CRAN and installed with
--configure-args="--disable-opengl"
also ranoptions(rgl.printRglwidget = TRUE)
in the R session. - R Version: 4.3.2
- Platform: OS X
Note: I first saw this issue when helping someone who was using windows so I don't think it's a platform specific issue.
I haven't yet attempted to repro with the latest version from github. I will give that a try and perhaps also dig in the sourcecode.
There's also a possibility that I am misunderstanding what this argument is supposed to do. In that case, I would be happy to propose an edit do the document to make it more clear.
UPDATE: Also confirmed the same behavior when installing from github (41b9e90).
Currently there's no difference between Github and CRAN: 1.3.1 was just uploaded a few days ago. So this looks like a current issue.
I tried your code. It works properly in R, but the bug is present in WebGL (produced by rglwidget()
). So the code to look at is the Javascript code in inst/htmlwidgets/lib/rglClass
. From a quick glance, it appears to have 5 hardcoded for the xlen
setting, so this should be pretty easy to fix.
Thanks for the report! It's fixed now.
Thanks for the quick work! It's working for me (installed from github).