在 r 中绘制散点图 3D [英] drawing scatterplot 3D in r
问题描述
我想在 scatterplot3d 中可视化我的数据
I would like to visualize my data in a scatterplot3d
在我的 X 和 Y 轴上,我想要相同的标签.像这样:
On my X and Y axis, I would like the same lables. Something like this:
x<-c("A","B","C","D")
y<-c("A","B","C","D")
在Z轴上,我想展示X和Y标签之间的比较
on the Z axis, I would like to show the comparision between lables in X and Y
A with A
A with B
A with c
A with D
B with B
B with C
B with D
C with C
C with D
D with D
#altogether 10 values in Z
z<-c(0.25, 0.7, 0.35, 1.14, 0.85, 0.36, 0.69, 0.73, 0.023, 0.85)
现在我想在 scatterplot3d
上绘制所有这些信息.我如何在 scatterplot3d 上实现这个概念?
Now I want to draw all of of these infos on scatterplot3d
. How can I implement this concept on scatterplot3d?
推荐答案
如果要绘制点,则需要匹配 (x,y,z)
值的三元组.您可以创建与 z
中的位置匹配的 x
和 y
值与
If you want to plot points, you need to match triplets of (x,y,z)
values. You can create x
and y
values matching the positions in z
with
xx <- factor(rep(x, 4:1), levels=x)
yy <- factor(unlist(sapply(1:4, function(i) y[i:4])), levels=y)
然后你可以用
library(scatterplot3d)
scatterplot3d(xx,yy,z,
x.ticklabs=c("",x,""), y.ticklabs=c("",y,""),
type="h", lwd=2,
xlim=c(0,5), ylim=c(0,5))
得到
但老实说,这似乎不是一个特别有效的可视化.
But honestly this doesn't seem like a particularly effective visualization.
这篇关于在 r 中绘制散点图 3D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!