plot3d - having two plots at once

后端 未结 3 606
情深已故
情深已故 2021-01-11 14:26

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

3条回答
  •  心在旅途
    2021-01-11 14:45

    An alternative to have "two 3d plots opened at once" is using mfrow3d from library("rgl"). It works the same way as par("mfrow") in classic R.

    The following adapted code (from here) produces two side-by-side 3D plots (2 columns) in one window:

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

提交回复
热议问题