保存RGL plot3d()图的方向

zac*_*ach 26 r rgl

我有一个使用RGL的3D图.我想用颜色制作相同的图来突出显示某些变量的分布.要做到这一点,我想有相同的情节,我如何找到和设置情节的方向?

一旦我做了一个初步的情节,我移动它找到一个很好的显示角度,我想保存这个角度,并将其纳入未来的绘图脚本.有人建议如何做到这一点?

library(rgl)
plot3d(iris) 
#play with the plot to find a good angle
#save the angle for future plots
Run Code Online (Sandbox Code Playgroud)

Jos*_*ien 21

本的评论基本上回答了你的问题; 这只适用expand.dots于他所写的内容;)

## In an inital session:

library(rgl)
plot3d(iris) 

## Now move the image around to an orientation you like

## Save RGL parameters to a list object
pp <- par3d(no.readonly=TRUE)

## Save the list to a text file
dput(pp, file="irisView.R", control = "all")

.......

## Then, in a later session, to recreate the plot just as you had it:

library(rgl)
pp <- dget("irisView.R")
plot3d(iris)
par3d(pp)
Run Code Online (Sandbox Code Playgroud)