我不是R专业人士,自学成才 - 谢谢你的帮助!
我已经找到了令我满意的以下代码,它给了我一个我的数据的三维图,我可以自动旋转它。但是,我想在旋转时停止自动重绘轴。我使用par3d找到了很多资源(skipRedraw = TRUE),但我无法弄清楚如何将它合并到我的代码中,这有点超出我的范围。
另外,(我打算放弃这个,但是因为我还是要问)我也希望能够让轴标签留在轴刻度标记旁边(而不是在它对面/另一边)。但这是次要的。
提前谢谢!
mydata<-read.csv(file=file.choose(),header=TRUE,row.names=1)
mydata$Colour<-factor(mydata$ColourB,levels=c("Black","Blue","Red","Green","Yellow","Purple","Brown"))
colourb<-as.character(mydata$ColourB)
library(rgl)
open3d()
plot3d(mydata[,"Sr"],
mydata[,"Rb"],
mydata[,"Zr"],
xlab="Sr (ppm)",
ylab="Rb (ppm)",
zlab="Zr (ppm)",
pch=21,
col=colourb,
type="s",
radius=10
)
bgplot3d({
plot.new()
title(main = 'Trace Elements', line = 1)
})
play3d(spin3d(axis=c(0,0,1), rpm=10), duration=10)
答案 0 :(得分:0)
很容易停止自动重绘轴。使用bbox轴(默认)时,会重绘它们。所以你只需使用固定位置轴。 (编辑:我可能会误解你的不安。)
以下是我的示例(使用数据trees
):
open3d()
plot3d(trees, type="s", radius=0.4, col="red", xlab="xxx", ylab="yyy", zlab="zzz",
axes=F) # not use bbox-axes
axes3d(edges = c("x","y","z")) # draw fixed position axes
box3d() # if you need, draw full box
bgplot3d({
plot.new()
title(main = 'Trees', line = 1)
})
play3d(spin3d(axis=c(0,0,1), rpm=10), duration=10)
# PS: skipRedraw isn't what you think.
plot3d(trees)
par3d(skipRedraw = T) # you can't turn the graph by drag