【问题标题】:Coloring a curve in the 3D space with CSV data使用 CSV 数据为 3D 空间中的曲线着色
【发布时间】:2015-06-04 18:36:28
【问题描述】:

我已经为这种情况苦苦挣扎了好几天,非常感谢您的建议。

我有一个在 C++ 中运行的模拟,最后我得到一个包含 4 列的 .csv 文件:t、L_1(t)、L_2(t)、L_3(t)。

我要绘制的函数是 L(t) = L_1(t)i + L_2(t)j + L_3(t)k , L(0) = (0,0,0)。

我想在 3D 图表中绘制函数 L(t) 在数据表中经过时间的路径。另外,我还希望将时间(对数)作为色标,表示函数的演化路径。

我尝试了几个选项,但没有一个能真正达到我的预期。你能帮帮我吗?

谢谢!

【问题讨论】:

    标签: csv plot colors 3d wolfram-mathematica


    【解决方案1】:

    这最容易直接作为Line 图形:

     data = Table[ { t, Sin[t] , Cos[t] , (t/20)^2 } , {t, 0, 20, .5 }];
     Graphics3D@Line[ data[[All, 2 ;; 4]]]
    

    你可以使用VertexColors给它着色

    你也可以做插值然后使用ParametricPlot3D

     interp = Table[ Interpolation[data[[All, i]]] , {i, 2, 4}]
     ParametricPlot3D[Through@interp[t], {t, 1, 40}]
    

    有了这个,你可以使用InterpolationOrder 选项来控制平滑。

    彩色(并带有InterpolationOrder->1

     ParametricPlot3D[Through@interp[t], {t, 1, 40},
           ColorFunction -> Function[{x, y, z, t}, Hue[t]]]
    

    【讨论】:

      猜你喜欢
      • 2017-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多