在绘图中使用表面绘图功能

时间:2019-08-18 12:00:59

标签: r plotly

我希望使用R中的某些数据创建一些3d平面图。我有一个包含许多变量的大型数据框,但我只想显示3(距离,年份和死亡率) )。我一直在尝试使用一两天的曲面图库,但是我什么也无法显示。我可以让其他库工作。这是我目前正在使用的代码-

cold3Dplot <- plot_ly(showscale = FALSE) %>%
  add_surface(z = ~as.matrix(filtered$distance,2014,filtered$RelativeDeaths.2014),opacity = 0.98) %>%
  add_surface(z = ~as.matrix(filtered$distance,2015,filtered$RelativeDeaths.2015),opacity = 0.98) %>%
  add_surface(z = ~as.matrix(filtered$distance,2016,filtered$RelativeDeaths.2016),opacity = 0.98)%>%
  add_surface(z = ~as.matrix(filtered$distance,2017,filtered$RelativeDeaths.2017),opacity = 0.98)

cold3Dplot

这是我过滤后的数据框的样子:

   datazone              label      code shape_area shape_leng stdareakm2 stdareaha hhcnt2011 respop2011 totpop2011
561 S01010318 S12000046S01010318 S01010318  128009.62   2950.044   0.128009 12.800961       304        505       1588
562 S01010319 S12000046S01010319 S01010319   96160.88   2282.814   0.096161  9.616090       407        711        711
599 S01010356 S12000046S01010356 S01010356  286149.89   4874.812   0.286150 28.614989       308        682        682
606 S01010363 S12000046S01010363 S01010363  157714.24   3083.966   0.157714 15.771425       394        758        758
563 S01010320 S12000046S01010320 S01010320   73061.83   1544.579   0.073063  7.306183       437        670        675
709 S01010466 S12000046S01010466 S01010466  529203.94   4393.694   0.529203 52.920395       458        879        879
                    name Feature.Name RelativeDeaths.2014 RelativeDeaths.2015 RelativeDeaths.2016 RelativeDeaths.2017
561         Ruchill - 04           NA                  -5                  -5                  -3                  -4
562         Ruchill - 05           NA                  -6                  -5                  -6                  -6
599   Maryhill West - 03           NA                  -5                  -6                  -2                  -9
606      Kelvindale - 01           NA                  -2                  -2                  -5                  -5
563         Ruchill - 06           NA                  -4                  -6                  -3                  -6
709 Anniesland East - 02           NA                  -5                  -7                  -3                   0
    AverageRelativeDeaths  distance       lon      lat ID OBJECTID                 Name TotPop2011 ResPop2011 HHCnt2011
561                    -4  30.44933 -4.278552 55.88277 24     3813         Ruchill - 04       1588        505       304
562                    -6  32.69077 -4.280502 55.88595 23     3814         Ruchill - 05        711        711       407
599                    -6  50.42398 -4.287960 55.89284 32     3851   Maryhill West - 03        682        682       308
606                    -4 105.39898 -4.309206 55.89306 10     3858      Kelvindale - 01        758        758       394
563                    -5 149.88008 -4.282008 55.88644 23     3815         Ruchill - 06        675        670       437
709                    -4 154.92867 -4.319477 55.89498 72     3961 Anniesland East - 02        879        879       458
    Easting Northing coords.x1 coords.x2 optional
561  257542   667848 -4.278992  55.88265     TRUE
562  257447   668188 -4.280688  55.88567     TRUE
599  256994   669045 -4.288377  55.89323     TRUE
606  255670   668966 -4.309488  55.89213     TRUE
563  257256   668176 -4.283733  55.88551     TRUE
709  254973   669173 -4.320734  55.89378     TRUE

但是就像我说的那样,我只对使用相对死亡,距离和年份感兴趣。

我到底在做什么错?我想至少要展示一些东西,然后才能知道我是否朝着正确的方向前进。

干杯!

0 个答案:

没有答案