【问题标题】:Set colorbar range for an mlab surface为 mlab 表面设置颜色条范围
【发布时间】:2017-08-25 08:59:31
【问题描述】:

我在互联网上四处寻找,但没有找到解决方案。

我正在使用mlab.pipeline.surface(mesh) 在同一个图中绘制不同的曲面。我想用相同的颜色条绘制它们。

在此图中,表面的右侧部分处于相同的温度,但由于每个表面的颜色条范围不同,因此颜色也不同。 我认为应该有类似matplotlib.tricontourf(...,levels=...) 的东西来修复颜色条范围。

如何使用mlab 设置颜色条范围?

【问题讨论】:

  • 你能发布一个简短的例子来说明你想要实现的目标吗?做出潜在的答案会容易得多。 Stackoverflow 有一个help page about it

标签: python plot colorbar mayavi


【解决方案1】:

您可以查看 mlab 的内置文档。来自help(mlab.pipeline.surface)

:vmax: vmax is used to scale the colormap.
       If None, the max of the data will be used

:vmin: vmin is used to scale the colormap.
       If None, the min of the data will be used

换句话说,您需要计算每个数据集的数据的全局最小值和全局最大值,并为每个表面设置相同的极值。请注意,您可以使用 matplotlib 的 3d 绘图方法执行完全相同的操作(甚至使用完全相同的关键字)。

切向注意:您的用例也可能受益于一些透明度,因为您的表面可能会相互重叠,这可能会阻碍可视化。想到的两个关键字是opacity 和可能(尽管可能性较小)transparent

:opacity: The overall opacity of the vtk object. Must be a float.
          Default: 1.0
:transparent: make the opacity of the actor depend on the
              scalar.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-23
    • 2011-02-02
    • 1970-01-01
    • 2016-01-21
    • 2017-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多