3D surface plot in R

后端 未结 2 1564
感动是毒
感动是毒 2020-12-20 00:28

I\'m trying to create a 3D plot in R-Project. I know there was a question like this before but I couldn\'t solve my problems with the answers there.

What I have is:<

相关标签:
2条回答
  • 2020-12-20 01:23

    So something like this??

    library(rgl)
    zlim        <- range(P,na.rm=T)
    zlen        <- zlim[2] - zlim[1] + 1
    color.range <- rev(rainbow(zlen))       # height color lookup table
    colors      <- color.range[P-zlim[1]+1] # assign colors to heights for each point
    persp3d(Vdot_L, Qdot_verd, P, col=colors)
    
    0 讨论(0)
  • 2020-12-20 01:31

    Have you investigated the Plot3D package? http://cran.r-project.org/web/packages/plot3D/plot3D.pdf There's a method in here called surf3d which seems like it would do what you want. After importing the package, cast your values to matrix and write:

    surf3d(Vdot_L, Qdot_verd, P)
    

    There's also a color parameter which you can adjust.

    Alternatively, use rgl, and avoid the matrix issue:

    rgl.surface(Vdot_L, Qdot_verd, P)
    

    Also check out these posts for more info: R: 3D surface plot from 2D matrix How to create 3D - MATLAB style - surface plots in R

    0 讨论(0)
提交回复
热议问题