What hardware limits plotting speed in R?

前端 未结 2 1228
走了就别回头了
走了就别回头了 2021-01-01 22:19

I would like to increase the speed of plotting, and I am happy with (and have lots of code requiring) the R graphics and ggplot packages - so I am only interested in knowing

2条回答
  •  一整个雨季
    2021-01-01 22:41

    As @Xu Wang points out, you can use parallelization to draw several plots at once.

    So hardware wise, a powerful fast multi-core machine with plenty of RAM would help a bit.

    If you want to plot a single plot with, say, 1 million circles in an x-y plot (scatter plot), then graphics hardware acceleration would be very beneficial.

    But a fast graphics card only helps if the graphics devices in R support hardware acceleration. Currently they do not - and as @hadley points out, ggplot uses the standard graphics devices.

    The rgl package apparently uses OpenGL to do 3D-graphics. Haven't tried it though. You might be able to use it to draw some plots more efficiently...

    I have some experience creating fast interactive hardware accelerated plots (2d and 3d), and it can be magnitudes faster. The 2d-plots are actually harder to accelerate than the 3d ones... Probably not an easy thing to plug into R's current graphics device concept though.

    UPDATE I just tried rgl and its plot3d with 1 million points. It is fully interactive (small fractions of a second to update) on my (rather powerful) laptop.

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

提交回复
热议问题