r plotly 3d surface plot issue

妖精的绣舞 提交于 2019-12-01 06:48:13

add_surface requires x and y to form a grid and z to be a matrix over that grid. Without knowing exactly what your data are and what you want to do, I can only guess how to do that:

library(akima)

# interpolate data onto grid
test_plotly <- with(test_plotly, interp(Age, BMI, Task_Completion_Time,
                                        duplicate = "mean"))

# plot surface over grid
plot_ly(x = test_plotly$x, y = test_plotly$y, z = test_plotly$z,
        type = "surface")

will give you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!