根据点的高度(在python/mayavi中),是否可以改变iso-surface的颜色? 我可以用我的脚本创建一个iso-surface可视化,但是我不知道如何用z轴改变iso_surface的颜色,这样我们可以说黑色在底部,白色在顶部。 我需要这个以便从图上方直观地看到可视化。 如果你知道任何其他方式来实现这一点,请让我知道。 我只想显示一个iso_surface图。根据Mayavi中的高度改变颜色iso_surface
1
A
回答
1
我设法通过结合来自例子http://docs.enthought.com/mayavi/mayavi/auto/example_atomic_orbital.html#example-atomic-orbital和http://docs.enthought.com/mayavi/mayavi/auto/example_custom_colormap.html的一些代码来做到这一点。基本上你必须像在原子轨道的例子中一样创建一个表面,然后根据x改变颜色。您必须为x创建一个数组值。我的代码(相关部分):
#src.image_data.point_data.add_array(np.indices(list(self.data.shape)[self.nx,self.ny,self.nz])[2].T.ravel())
src.image_data.point_data.add_array(np.indices(list(self.data.shape))[0].T.ravel())
src.image_data.point_data.get_array(1).name = 'z'
# Make sure that the dataset is up to date with the different arrays:
src.image_data.point_data.update()
# We select the 'scalar' attribute, ie the norm of Phi
src2 = mlab.pipeline.set_active_attribute(src, point_scalars='scalar')
# Cut isosurfaces of the norm
contour = mlab.pipeline.contour(src2)
# contour.filter.contours=[plotIsoSurfaceContours]
# contour.filter.contours=[plotIsoSurfaceContours[0]]
min_c = min(contour.filter._data_min * 1.05,contour.filter._data_max)
max_c = max(contour.filter._data_max * 0.95,contour.filter._data_min)
plotIsoSurfaceContours = [ max(min(max_c,x),min_c) for x in plotIsoSurfaceContours ]
contour.filter.contours= plotIsoSurfaceContours
# Now we select the 'angle' attribute, ie the phase of Phi
contour2 = mlab.pipeline.set_active_attribute(contour, point_scalars='z')
# And we display the surface. The colormap is the current attribute: the phase.
# mlab.pipeline.surface(contour2, colormap='hsv')
xxx = mlab.pipeline.surface(contour2, colormap='gist_ncar')
colorbar = xxx.module_manager.scalar_lut_manager
colorbar.reverse_lut = True
lut = xxx.module_manager.scalar_lut_manager.lut.table.to_array()
lut[:,-1] = int(plotIsoSurfaceOpacity * 254)
xxx.module_manager.scalar_lut_manager.lut.table = lut
# mlab.colorbar(title='Phase', orientation='vertical', nb_labels=3)
self.data是我的数据,以及原因不明,如果你想设置你的表面的不透明度必须先颠倒的LUT,然后设置不透明度。乘以254而不是255是为了避免mayavi中可能的错误。 我希望这可以帮助某人。
相关问题
- 1. 根据iPhone颜色改变颜色
- 2. 根据进度更改seekbar颜色
- 3. Pyplot:根据类别改变颜色
- 4. 根据ggplot2中的高度显示条的颜色
- 5. 根据其位置更改导航栏颜色。颜色不变
- 6. css3是否可以根据宽度改变颜色?
- 7. Google热图根据亮度改变颜色
- 8. 如何根据UILablel的高度来改变UIView的高度?
- 9. 根据值更改颜色
- 10. 根据SGPlot中的数据值改变标记颜色 - SeriesPlot
- 11. 改变颜色的颜色
- 12. 根据数据更改图例颜色高图表
- 13. 根据值更改高度
- 14. 根据“多种因素”斜率改变ggplot中的线颜色
- 15. D3根据数据改变链接的颜色
- 16. 崇高的文字/ textmate配色方案 - 改变高亮颜色
- 17. PHP JSON根据值的颜色变化
- 18. 如何更改iphone中UISearchBar的UiSearchbar高度,宽度,颜色和Uitextfield高度?
- 19. 根据选定的颜色更改颜色
- 20. 根据轮廓颜色的颜色点
- 21. 改变颜色
- 22. 改变颜色
- 23. 改变颜色
- 24. 改变颜色
- 25. 改变颜色
- 26. 改变颜色
- 27. 改变颜色
- 28. 改变颜色
- 29. 改变颜色
- 30. [PHP/AJAX]:根据输入的文字改变信息的颜色