plot3d - having two plots at once

CodeGuy picture CodeGuy · Feb 5, 2013 · Viewed 8.5k times · Source

plot3d() produces a 3d plot that I can twist around and rotate. But when I call plot3d() again, the previous plot goes away and is replaced by this one.

How can I make it so that a new XQuartz window opens up rather than the old window being replaced by the new 3d plot.

Essentially, I want two 3d plots opened at once.

Answer

user1317221_G picture user1317221_G · Feb 5, 2013

like this:

 library(rgl)

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

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

The key here is calling open3d before the second plot to open a new "device"