2016-06-30 264 views
-1

我有3個變量x,yz。我想做一個曲面圖,實現這樣的https://plot.ly/r/3d-surface-plots/R中的3D表面圖

我想:

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計數而不是變量

回答

0

這類作品。

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

enter image description here

+0

謝謝...但是這表明Y上而不是實際值的行數。有沒有辦法可以改變它 – Keniajin