R: 4D plot, x, y, z, colours

前端 未结 3 1213
抹茶落季
抹茶落季 2020-11-28 10:53

Could you give me an example on how to use rgl to plot 3 variables at the axes x, y and z and a fourth one with different colours?

thanks

3条回答
  •  迷失自我
    2020-11-28 11:16

    Take a look at example(points3d).

    The r3d help page shows you how to draw axes.

    x <- c(0, 10, 0, 0)
    y <- c(0, 0, 100, 0)
    z <- c(0, 0, 0, 1)
    i <- c(1,2,1,3,1,4)
    labels <- c("Origin", "X", "Y", "Z")
    text3d(x,y,z,labels)
    segments3d(x[i],y[i],z[i])
    

    Now you add some points

    dfr <- data.frame(x = 1:10, y = (1:10)^2, z = runif(10), col = rainbow(10))
    with(dfr, points3d(x, y, z, col = col))
    

提交回复
热议问题