r plotly 3d surface plot issue

前端 未结 1 1901
野性不改
野性不改 2020-12-19 11:58

I am trying to plot a 3d surface plot based on these plotly examples

When I try these examples on my dataset

 test_plotly =   structure(list(Age = c         


        
相关标签:
1条回答
  • 2020-12-19 12:33

    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

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