问题标签 [mayavi.mlab]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
1666 浏览

python - mlab.axes 的轴控制

这只是一个小问题。我使用下面的句子来控制三个轴范围。

事实上,真实的数据范围分别是 (3000,4000),(5000,6000),(0,22)。然而,我绘制的图形的轴被缩放到(0,10000,0,10000,0,22)。

我没有找到可以控制mlab.axes 的参数。

我每次都必须计算数据范围吗?在不知道真实数据范围的情况下,有没有办法让轴范围服从真实数据?

0 投票
1 回答
708 浏览

mayavi - 在 Mayavi Mlab 中设置体素颜色和透明度

如何在 Mayavi Mlab 中设置特定体素的颜色和透明度?

0 投票
1 回答
2434 浏览

python - mlab savefig 不保存图像

所以我正在尝试使用 Mayavi 保存一个数字。代码如下所示。

数据可以在屏幕上呈现。例如: 截屏

但不幸的是,当我这样做时savefig(),似乎有问题。我得到一个空白的数字。我什至尝试使用screenshot()并绘制它,pylab.imshow()但结果也是空白。我什至尝试使用 mlab 窗口上的保存按钮直接保存,即使这给出了一个空白图像!

我已经检查过 [ mayavi mlab.savefig() 给出了一个空图像] 但这似乎没有起到作用。

我开始怀疑后端有问题。我在带有 Qt 后端的 Windows 7 系统上使用 wxPython。我还尝试了几乎所有我拥有的后端,即使是普通的非交互式控制台,它也不起作用。

有人对这个有经验么??

0 投票
2 回答
1806 浏览

numpy - 使用(mayavi)mlab.contour3d 绘制存储在文件中的数据?

我正在努力使用从文件中读取的数据在 mayavi 中绘制简单的轮廓 3d 绘图。数据是一个规则的 3d 笛卡尔网格,形式为

(这里每行的前 3 个值给出了该点的 (x,y,z) 坐标,而第 4 个值给出了该点的标量值。如果有用,我可以粘贴一个最小的示例文件)

可以使用 numpy.loadtxt 成功读取数据文件,但是如何从那里使用 (mayavi) mlab.contour3d 绘制等值面?我认为 loadtxt 的默认输出数组的格式不适合 mlab.contour3d。

我能够找到的所有 mlab.contour3d 示例都使用 ogrid 生成一个网格,然后绘制该网格的一个简单函数(sin 等)。我已经能够成功运行这些示例,但是它们没有告诉我如何将文件中的数据读入准备好绘图的正确格式的数组。如果有人能给我指点,我相信它会帮助很多处于类似位置的新手;绘制存储在另一个程序生成的文件中的 3D 数据肯定是科学家必须做的最常见的绘图任务之一。

0 投票
1 回答
573 浏览

python - Enthought mlab non-framework build of python does not have access to screen

Using Enthought Canopy v1.4 on Mac (Mavericks) I have Canopy setup as my default Python environment.

Whenever I try to call mlab.show() or mlab.savefig() it fails with:

Python is loaded from ~/Library/Enthought/Canopy_64Bit/System/Python which is a symlink to Applications/Canopy/appdata/canopy-1.4.0.1938.macosx-x86_64/Canopy/Contents/Python

Is there any way I can keep using Canopy (for its easy install of Mayavi/mlab) and use a Framework build of python for Terminal use?

0 投票
1 回答
1731 浏览

python - 更改 mlab quiver3d 和 surf 数据源而不清除特征脚本中的图形

我有一个 Traits 和 Mayavi 脚本,它展示了一个 mlab 场景和几个特征编辑器。编辑器通过调用我的绘图方法来影响显示在 a 和图例(标量 LUT 管理器)surface中的数据。quiver3d每次更改都会触发清晰的图形并重新绘制。

Mlab 交互式对话框示例中学习plot3d* 用于mlab_source.set更改数据而无需清除图形并重新绘制。在 update_plot() 中:

mysurfacequiver3d调用的返回分别是mayavi.modules.surface.Surfacemayavi.modules.vectors.Vectors对象。Surface 和 LUTManager 报告没有 mlab_source: AttributeError: 'Surface'/'LUTManager' object has no attribute 'mlab_source'。Quiver3d 报告了一个mayavi.tools.sources.MGlyphSource

1)如何更改我的数据/源surfacescalar LUTManager

2) 如何正确更改箭袋的数据/来源?

当我尝试更改 quiver 的值时,我得到了TraitError: Cannot set the undefined 'u' attribute of a 'Vectors' object.This 让我感到困惑,因为我使用了六值初始化程序


在示例中,plot3d返回 amayavi.modules.surface.Surface并且它的mlab_source对象是 a mayavi.tools.sources.MLineSource。在文档中搜索MLineSource是徒劳的,但在外部会产生Enthought Tool Suite 3.2结果。Tool Suite 文档是最新的吗?

*self.plot、self.surface 和 self.quiver 被声明为variable = Instance(PipelineBase). PipelineBase是从 导入的mayavi.core.api

0 投票
0 回答
1061 浏览

python-2.7 - Python Enthought Mayavi crashes on data update using mlab_source.reset

I'm trying to update data in a mayavi 3D plot. Some of the changes to the data don't affect the data shape so the mlab_source.set() method can be used (which updates underlying data and refreshes the display without resetting the camera, regenerating the VTK pipeline, regenerating the underlying data structure, etc. This is the best possible case for animation or quick plot updates.

If the underlying data changes shape, the documentation recommends using the mlab_source.reset() method, which while not recreating the entire pipeline or messing up the current scene's camera, does cause the data structure to be rebuilt, costing some performance overhead. This is causing crashes for me.

The worst way to go is completely deleting the plot source and generating a new one with a new call to mlab.mesh() or whatever function was used to plot the data. This recreates a new VTK pipeline, new data structure, and resets the scene's view (loses current zoom and camera settings, which can make smooth interactivity impossible depending on the application).

I've illustrated a simple example from my application in which a Sphere class can have it's properties manipulated (position, size, and resolution). While changing position and size cause the coordinates to refresh, the data remains the same size. However changing the resolution affects the number of latitude and longitude subdivisions used to represent the sphere, which changes the number of coordinates. When attempting to use the "reset" function, the interpreter crashes completely. I'm pretty sure this is a C level segfault in the VTK code based on similar errors around the web. This thread seems to indicate the core developers dealing with the problem almost 5 years ago, but I can't tell if it was truly solved.

I am on Mayavi 4.3.1 which I got along with the Enthought Tool Suite with Python(x, y). I'm on Windows 7 64-bit with Python 2.7.5. I'm using PySide, but I removed those calls and let mlab work by itself for this example.

Here's my example that shows mlab_source.set() working but crashes on mlab_source.reset(). Any thoughts on why it's crashing? Can others duplicate it? I'm pretty sure there are other ways to update the data through the source (TVTK?) object, but I can't find it in the docs and the dozens of traits related attributes are very difficult to wade through.

Any help is appreciated!

EDIT:

I just verified that all of these mlab_source tests pass for me which includes testing reset on an MGridSource. This does show some possible workarounds like accessing source.mlab_source.dataset.points ... maybe there's a way to update the data manually?

EDIT 2:

I tried this:

It appears that modifying the TVTK Polydata object directly partly works. It appears that it's updating the points without also auto-fixing the connectivity, which is why I have to also run the mlab_source.reset(). I assume the reset() can work now because the data coming in has the same number of points and the mlab_source handles auto-generating the connectivity data. It still crashes when reducing the number of points, maybe because connectivity data exists for points that don't exist? I'm still very frustrated with this.

EDIT 3:

I've implemented the brute force method of just generating a new surface from mlab.mesh(). To prevent resetting the view I disable rendering and store the camera settings, then restore the camera settings after mlab.mesh() and then re-enable rendering. Seems to work quick enough - still wish underlying data could be updated with reset()

Here's the entire class I use to manage plotting objects (responds to GUI signals after an edit has been made).

0 投票
0 回答
320 浏览

python - Mayavi/Python 将不规则数组中的图像绘制为垂直平面

这是我想要做的:我有一个表面,我想要一个 3D 绘图和一个数组,我想在表面下方绘制一个垂直平面。曲面与平面应形成T型可视化。该数组包含值,并且我将值的相应 x 和 y 坐标存储在其他 2 个数组中(间距不规则)。

这是我到目前为止一直在尝试的......:

0 投票
1 回答
898 浏览

python - mayavi surf() 如何显示颜色条?

我不知道如何让颜色条显示。我没有太多使用 mayavi 的经验,所以我不确定我需要采取哪些步骤才能解决这个问题?

其他人有类似的问题我的代码如下所示:

0 投票
1 回答
1582 浏览

python - mayavi 在表面上映射离散颜色条

我想根据另一个采用离散值的值(ID)来改变表面的颜色(所以我需要一个离散的颜色条)。在下面的简化示例中,我绘制了一个具有 3 个不同 ID 的球体:

0/左边红色

2/蓝色在中间

1/左边的绿色

但是使用下面的代码,我在红色和蓝色之间的极限处获得了一些奇怪的行为(绿点)。这可能是因为插值!

编码:

图片

在 mlab.show() 之前我也尝试过这一行:

渲染效果更好,但绿点变成了绿条。

图片