6

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?

Community
  • 1
  • 1
SAN
  • 2,219
  • 4
  • 26
  • 32
  • It is rather a bug you should report to the [package author](http://cran.r-project.org/web/packages/rgl/index.html). – mbq Mar 02 '11 at 10:50
  • maybe, but it might be a mistake in installation, please report your operating system (and version), version of R, and package version of rgl: sessionInfo() is good after library(rgl) – mdsumner Mar 02 '11 at 11:11
  • 2
    That's a relatively old version of R, try upgrading to R 2.12.2 - if it's still a problem, and your set up is said to be supported, then you've got something to report to the rgl maintainer – mdsumner Mar 02 '11 at 13:44
  • @Dirk Eddelbuettel Thanks, i have updated my previous questions – SAN Mar 02 '11 at 14:46

2 Answers2

3

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?

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Can it also happen like it works perfectly some times and crashes some times on the same machine? Because i am able to generate a plot and unable to generate other – SAN Mar 02 '11 at 14:19
  • If it is a different plot function, code or data then there may be an error in your logic. Try re-running the same function. Try running the `demo()` illustrations which comes with the package. – Dirk Eddelbuettel Mar 02 '11 at 14:37
1

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

Contango
  • 76,540
  • 58
  • 260
  • 305