A year ago the following code used to show an output, but not it doesn't. No error is shown either. I'm reading the package changes but can't identify the reason.
library(rgl)
x1 <- seq(0, 2, len = 20)
x2 <- seq(0, 2, len = 20)
y <- outer(x1,x2, function(x1,x2) 1 + x1*2 + x2)
persp3d(x=x1, y=x2, z=y, theta = 30, phi = 30, expand = 1, col = "green")
surface3d(x=x1, y=x2, z=y, back = "lines")
surface3d(x=x1, y=x2, z=y, front = "lines")
bgplot3d({
plot.new()
title(main = 'y = 1 + 2*x1 + x2', line = 3)
})
I tried to reproduce your problem and ran into the same problem myself. The issue here is that
rglis defaulting to using the "null" device ... and when I tried to explicitly stop that,This led me to how it was installed this time, and I found in the installation log (on the R console):
Notably the
compiling without OpenGL supportpart. (I'm running ubuntu-23.04 using wayland, if it matters.)Looking at the installation instructions, it mentions the OS packages
libgl1-mesa-devandlibglu1-mesa-dev, and lo-and-behold they were not installed on my system. On a shell (not R) prompt, I confirmed this absence with:After installing them with:
(much output), I then uninstalled the R package
rgland compiled it again from scratch.noting subjectively that it took longer because it had more files to compile and link. Once that finished and I restarted R (necessary, I think),
produced a plot: