Help in using rgl package

5.2k Views Asked by At

I installed rgl package with the option --disable-libpng. I tried generating a 3d scatter plot and it crashes. Please help me in resolving this

This is the code i am running

library(rgl)
open3d()
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x,y)
plot3d(x, y, z, col=rainbow(1000))

It crashes with below messages

 *** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
 1: .External(rgl_par3d, args)
 2: par3d(skip)
 3: plot3d.default(x, y, z, col = rainbow(1000))
 4: plot3d(x, y, z, col = rainbow(1000))

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:

Here is the information from sessionInfo()

    > sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-unknown-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgl_0.92.798

This is from the sysname command

x86-64_linux_2.6.16_ImageSLES10SP3-3

Some more info:

I am able to generate a surface plot from some code in R: Plotting a 3D surface from x, y, z

Here is the code

x <- seq(-10, 10, length.out = 50)
y <- x
rotsinc <- function(x,y) {
    sinc <- function(x) {
        y <- sin(x)/x;
        y[is.na(y)] <- 1;
        y
    }
    10 * sinc( sqrt(x^2+y^2) )
}
z <- outer(x, y, rotsinc)

surface3d(x, y, z)

I tried demo(rgl) and that is also crashing with similar message. I want to generate 3d plots, which other package do you recommend? ggplot?

2

There are 2 best solutions below

2
On BEST ANSWER

The rgl package makes use of possible hardware acceleration in your graphics card via its driver.

This is unfortunately entirely dependent on the driver. I have been using rgl for animated visualization for a number of years---see eg this visualization of option analytics surfaces from 2005---which I can assure you crashed for no good reason on some machines and runs on others. You really should try on a different machine with a different driver before making any firm conclusions.

Computers use hardware, and sometimes the hardware bites. I can your code fine on one of my machines. Another is dual-screen and hence without GL extension so it won't. Did I mention hardware bites?

0
On

I tested the exact same code on my system, and it worked perfectly.

Whatever the issues were, they have probably been fixed.

Test 1:

library(rgl)
demo(rgl)

Test 2:

library(rgl)
open3d()
x <- sort(rnorm(1000))
y <- rnorm(1000)
z <- rnorm(1000) + atan2(x,y)
plot3d(x, y, z, col=rainbow(1000))

My system is Windows 7 x64 running R v2.14.2. Tested under two IDEs, namely Revolution R and RStudio.

enter image description here