gpt4 book ai didi

R:以非交互方式导出 3D 散点图

转载 作者:行者123 更新时间:2023-12-04 12:13:40 24 4
gpt4 key购买 nike

在 R 中创建 3D 绘图会打开一个交互式窗口,用户可以在其中旋转 View 。例如下面使用包 rgl:

library(rgl)
plot3d(iris[,1:3],col=c("red","green","blue")[iris$Species],size=5)

enter image description here

有什么方法可以设置预定义 View 并将绘图导出为常规图像。对于许多数据集,我想以自动化的非交互方式执行此操作。

最佳答案

使用 scatterplot3d 包。

library(scatterplot3d)
graphics.off()
png(filename = "test.png", width = 8, height = 6, units = "in", res = 300)
par(mai = c(0.5, 0.5, 0.5, 0.5))
scatterplot3d(x = iris$Sepal.Length, y = iris$Sepal.Width, z = iris$Petal.Length,
color = c("red","green","blue")[iris$Species],
cex.symbols = 1, pch = 19, angle = -30)
dev.off()

enter image description here

关于R:以非交互方式导出 3D 散点图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48691183/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com