R

时间:2016-06-30 14:47:35

标签: r 3d contour plotly

我有3个变量xyz。我想做一个表面图并实现类似https://plot.ly/r/3d-surface-plots/

的东西

我试过了:

library(plotly)
plot_ly(z = xy, type = "surface")

xy如下

xy <- read.table(text = "x,y,z
-0.2,-0.4,1
                 -0.116,0.29,0.489
                 -2.416,-1.949,-0.723
                 -0.572,-0.524,-0.331
                 1.71,1.351,0.275
                 -2.708,-0.801,1.357
                 -0.849,0.318,1.256
                 1.1,0.62,-0.179
                 -3.093,-1.344,0.898
                 -1.256,-2.862,-3.193
                 -2.909,-1.745,0.127
                 -0.041,-0.416,-0.646
                 -0.34,-0.273,-0.162
                 1.115,0.442,-0.486
                 0.083,-0.071,-0.279
                 0.322,0.902,1.042
                 -0.515,-0.863,-0.896
                 -4.044,-2.255,0.397
                 -0.865,-0.99,-0.693
                 -0.456,-1.381,-1.794", header = TRUE, sep = ",")

但它没有显示y而不是变量的计数

1 个答案:

答案 0 :(得分:0)

这种作品。

library(plotly)
plot_ly(z = as.matrix(xy) , type = "surface")

enter image description here