Wednesday, April 24, 2013

RG#86: 3D XY plot with sphare plots (interactive)

# data
myd <-data.frame(name =c("A","B","C","D", "E"),
var_x=c(6,7,11,1,8),
var_y=c(9,2,9,4, 2),
var_z=c(4,1,6,5,1),
point_size=c(6,3,6,3, 5)
)
myd$pradius <- myd$point_size*0.15

require(rgl)

spheres3d(myd[,2:4], radius = myd[,6], col = c("darkred", "green", "yellow", "orange", "purple"), alpha = 0.8)
axes3d(box = TRUE)

#title3d(xlab = "var_x", ylab = "var_y", zlab = "var_z")
#text3d(myd[1,2:5], texts = "A")

segs <- rbind(myd[1:2,2:5], myd[2:3,2:5], myd[3:4,2:5], myd[4:5,2:5], myd[c(5,1),2:5])
segments3d(segs, col = "blue", lwd = 2)

# take a SNPshot
rgl.snapshot ("my3dplot.png", fmt = "png")





# you can rotate the axis and take another snapshot, and shave as different name
rgl.snapshot ("my3dplot2.png", fmt = "png")

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.