mayavi

Basic 3D voxel grid in Mayavi

点点圈 提交于 2021-01-27 10:19:55
问题 I'm trying to visualize a 3D array through Mayavi in Python. I simply want to create a structured 3D voxel grid in which I can show some pre-specified voxel-space-filling points. I do not think that I want The only example that I can find that I think is relatively relevant is this MRI example. I can use the following code to get a somewhat workable example: import numpy as np from mayavi import mlab data = (100, 100, 100) data = np.zeros(data) data[0:50, 50:70, 0:50] = 1 data[0:50, 0:20, 0

mayavi 3d object in matplotlib Axes3D

孤者浪人 提交于 2021-01-22 13:22:11
问题 I sometimes find myself frustrated with the lack of certain rendering features in matplotlib's mplot3d. In most of these cases, I do find that I can get what I want in mayavi, but still the matplotlib 3d axes are preferable, if only for aesthetics, like LaTeX-ified labels and visual consistency with my other figures. My question here is about the obvious hack: is it possible to draw some 3d object (a surface or 3d scatter plot or whatever) in mayavi without axes, export that image, then place

installing mayavi with pip - Building TVTK classes…Assertion failed

这一生的挚爱 提交于 2020-12-02 00:12:46
问题 I've been trying to install mayavi in Yosemite. I've already installed the Numpy, VTK, wxPython, and configobj. When I run sudo pip install mayavi , it shows the following error msg: Running setup.py install for mayavi ---------------------------------------------------------------------- Building TVTK classes...Assertion failed: ("pre: not_empty" && !IsEmpty()), function GetAttributesToInterpolate, file /tmp/vtk-MvPwfE/VTK-6.1.0/Common/DataModel /vtkGenericAttributeCollection.cxx, line 453.

installing mayavi with pip - Building TVTK classes…Assertion failed

感情迁移 提交于 2020-12-02 00:07:55
问题 I've been trying to install mayavi in Yosemite. I've already installed the Numpy, VTK, wxPython, and configobj. When I run sudo pip install mayavi , it shows the following error msg: Running setup.py install for mayavi ---------------------------------------------------------------------- Building TVTK classes...Assertion failed: ("pre: not_empty" && !IsEmpty()), function GetAttributesToInterpolate, file /tmp/vtk-MvPwfE/VTK-6.1.0/Common/DataModel /vtkGenericAttributeCollection.cxx, line 453.

Mayavi imshow obscures quiver3d

末鹿安然 提交于 2020-08-08 06:49:32
问题 I am trying to overlay a quiver3d plot over an imshow plot in mayavi . The code I am using looks something like this: from mayavi import mlab import numpy as np img = np.random.uniform(0, 255, size=(512, 512)).astype(np.int) N = 10000 event_size = 2 xs = np.random.uniform(img.shape[1], size=N) ys = np.random.uniform(img.shape[0], size=N) ts = np.sort(np.random.uniform(1000, size=N)) ps = np.random.randint(0,2,size=N) mlab.imshow(img, colormap='gray', extent=[0, img.shape[0], 0, img.shape[1],

animating with mayavi mlab.points3d

六月ゝ 毕业季﹏ 提交于 2020-06-16 18:40:55
问题 Hello everyone i am trying to animate some data using Mayavi mlab.points3d and having some issues. Here is my code: import numpy as np from mayavi import mlab ##Some lists to animate px=np.arange(0,10000,1) py=np.arange(0,50000,5) ##Animation function def run(px,py): cc = mlab.gcf().scene.camera cc.position[-1] = 10 T_max = len(px) delayer=40 @mlab.animate(delay=delayer) def anim_loc(): f = mlab.gcf() while True: for i in np.arange(0,T_max,1): s=0.5 mlab.points3d(px[i],py[i],s,color=(0,0,0)

animating with mayavi mlab.points3d

你。 提交于 2020-06-16 18:39:08
问题 Hello everyone i am trying to animate some data using Mayavi mlab.points3d and having some issues. Here is my code: import numpy as np from mayavi import mlab ##Some lists to animate px=np.arange(0,10000,1) py=np.arange(0,50000,5) ##Animation function def run(px,py): cc = mlab.gcf().scene.camera cc.position[-1] = 10 T_max = len(px) delayer=40 @mlab.animate(delay=delayer) def anim_loc(): f = mlab.gcf() while True: for i in np.arange(0,T_max,1): s=0.5 mlab.points3d(px[i],py[i],s,color=(0,0,0)

Using perceptually uniform colormaps in Mayavi volumetric visualization

懵懂的女人 提交于 2020-01-23 12:47:11
问题 AFAIK Mayavi does not come with any perceptually uniform colormaps. I tried naively to just pass it one of Matplotlib's colormaps but it failed: from mayavi import mlab import multiprocessing import matplotlib.pyplot as plt plasma = plt.get_cmap('plasma') ... mlab.pipeline.volume(..., colormap=plasma) TraitError: Cannot set the undefined 'colormap' attribute of a 'VolumeFactory' object. Edit: I found a guide to convert Matplotlib colormaps to Mayavi colormaps. However, it unfortunately doesn

Probing/sampling/interpolating VTK data using python TVTK or MayaVi

丶灬走出姿态 提交于 2020-01-22 10:00:13
问题 I would like to visualise a VTK data file (OpenFOAM output) using python. The plot I would like to make is a 1-d line plot of a quantity between two endpoints. To do so, the unstructured data should be interpolated on the points which lie between the two endpoints. I've used the package Mayavi to visualise the VTK data. At the mayavi webpage there is a description of probing a single value from a scalarfield. This function does not work on a VTK file. Also I've found a delaunay3d method (mlab

Plotting a 3d data read from a file using mayavi

蓝咒 提交于 2020-01-16 04:28:27
问题 I have a data file in the following format: x y z f(x) f(y) f(z) I want to plot it using contour3d of mayavi: def fill_array(output_array,source_array,nx,ny,nz,position): for i in range(nx): for j in range(ny): for k in range(nz): output_array[i][j][k] = source_array[i][j][k][position] nx = 8 ny = 8 nz = 8 ndim = 6 x = np.zeros((nx,ny,nz)) y = np.zeros((nx,ny,nz)) z = np.zeros((nx,ny,nz)) fx = np.zeros((nx,ny,nz)) fy = np.zeros((nx,ny,nz)) fz = np.zeros((nx,ny,nz)) data_file = np.loadtxt(