简体   繁体   中英

drawing scatterplot 3D in r

I would like to visualize my data in a scatterplot3d

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")

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) 

Now I want to draw all of of these infos on scatterplot3d . How can I implement this concept on scatterplot3d?

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)

Then you can draw the plot with

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))

to get

在此处输入图片说明

But honestly this doesn't seem like a particularly effective visualization.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM