代码之家  ›  专栏  ›  技术社区  ›  massisenergy

无法使用plot\ly创建三维曲面

  •  0
  • massisenergy  · 技术社区  · 6 年前

    MWE:下图所示的数据帧。

    "TVF" "minEuler" "E_avg"
    29.63 -12 3.65
    30.00 -26 3.311
    30.24 -72 8.247
    30.82 -47 13.02
    20.25 -6 2.085
    14.53 -32 2.154
    14.66 -1 1.44
    24.12 -82 6.784
    21.25 -35 4.309
    25.82 -17 2.697
    26.15 -42 2.832
    18.38 -29 2.038
    18.51 -80 5.514
    14.67 -58 1.91
    20.40 -166 2.786
    26.50 -69 6.794
    40.97 -12 24.852
    18.98 -102 3.107
    19.15 -75 3.85
    40.54 -48 16.347
    35.09 -41 18.847
    28.15 -73 5.963
    40.25 -94 21.82
    24.28 -53 6.245
    30.34 -42 25.578
    

    代码:

    plot_ly(x = S_TVF_Euler_E_axes$TVF, y = S_TVF_Euler_E_axes$minEuler, 
            z = S_TVF_Euler_E_axes$E_avg, type = 'surface')
    

    输出:

    No surface is created

    目标:将曲面拟合到散点图(或直接绘制曲面)。我可以用 plot_ly 但表面不起作用。 我也试过了 this ,这对我不起作用。

    1 回复  |  直到 6 年前
        1
  •  1
  •   s__    6 年前

    interp 来自包的函数 akima . 我从“mschilli”的回答中得到了这个主意 here .

    > S_TVF_Euler_E_axes_plotly <- with(S_TVF_Euler_E_axes, interp(TVF, 
                                      minEuler, E_avg, duplicate = "mean"))
    > plot_ly(x = S_TVF_Euler_E_axes_plotly$x, y = S_TVF_Euler_E_axes_plotly$y, 
            z = S_TVF_Euler_E_axes_plotly$z, type = 'surface')
    

    Surface only