用 R 绘制 3D 图形
问题描述:
我有 3 个数据范围用于在 R 中绘图:
I have 3 data ranges using to plot in R:
x <- c(1,2,3,4,5)
y <- c(2,4,6,8,10)
z <- c(100,240,480,580,880)
如何使用 R 中的这些数据绘制 3D 图形(3d 散点图)?
How to plot a 3D graphic with those data in R (a 3d scatterplot) ?
答
只要稍微搜索一下,就有很多这样的例子.
There are many examples of this available with a bit of searching.
一些想法:
install.packages("scatterplot3d")
library(scatterplot3d)
s3d <-scatterplot3d(x,y,z, pch=16, highlight.3d=TRUE,
type="h", main="3D Scatterplot")
有时如果你能旋转它就很好:
Sometimes it is nice if you can rotate it:
install.packages("rgl")
library(rgl)
plot3d(x, y, z, col="red", size=3)