[英]How do I visualize 3 column data in R with a 3-dimensional plot?
I am quite new to R and more to plotting with it. 我对R很陌生,并且对使用R绘图更感兴趣。
I have this example data in a dataframe. 我在数据框中有这个示例数据。
head(dframe)
maingroup subgroup n
1 BR A 315
2 MV A 394
3 SAN A 253
4 BR B 230
5 MV B 242
6 SAN B 152
Now I want to visualize it: 现在我想形象化它:
If this is for publication (static image), you can use scatterplot3d
: 如果这是用于发布(静态图像),则可以使用
scatterplot3d
:
library(scatterplot3d)
DT <- data.frame(maingroup = letters[1:6], subgroup = letters[26:21], n = 1:6)
scatterplot3d(x = DT$maingroup, # x axis
y = DT$subgroup, # y axis
z = DT$n, # z axis
x.ticklabs = levels(DT$maingroup),
y.ticklabs = levels(DT$subgroup))
For something more interactive, you can use plotly
: 对于更具交互性的内容,可以使用
plotly
:
library(plotly)
plot_ly(x = DT$maingroup, # x axis
y = DT$subgroup, # y axis
z = DT$n, # z axis
type = "scatter3d")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.