mayavi

Mayavi Mlab : Drawing octahedrons

こ雲淡風輕ζ 提交于 2019-12-07 16:14:29
I cannot find a way to draw octahedrons. Could someone point me to a class for drawing triangular (transclucent) surfaces at the least? tvtk.tools.visual seems to have only a few basic shapes. The Gallery has an example of how to use triangular_mesh : import numpy as np import mayavi.mlab as ML verts = [(1,-1,0), (1,1,0), (-1,1,0), (-1,-1,0), (0,0,1), (0,0,-1)] x, y, z = zip(*verts) # Each triangle is a 3-tuple of indices. The indices are indices of `verts`. triangles = [(i, (i+1)%4, j) for i in range(4) for j in (4,5)] colorval = z ML.triangular_mesh(x, y, z, triangles, scalars=colorval,

Converting GUI-application into .exe-file with cx_Freeze: no plugin found for toolkit qt4

こ雲淡風輕ζ 提交于 2019-12-07 12:43:33
问题 My program contains mayavi, traits and pyqt5 elements in order to visualize something in 3D. I tried to convert my GUI-Application with cx_Freeze and it created the exe-file ,but running it I got the error: no traitsui.toolkits plugin found for toolkit qt4 After some google and stackoverflow research I figured out that it might has something to do with my environment: see creating standalone exe using pyinstaller with mayavi import According to the suggestions in further google research I

Update mayavi plot in loop

早过忘川 提交于 2019-12-07 12:30:50
问题 What I want to do is to update a mayavi plot in a loop. I want the updating of the plot to be done at a time specified by me (unlike, e.g., the animation decorator). So an example piece of code I would like to get running is: import time import numpy as np from mayavi import mlab V = np.random.randn(20, 20, 20) s = mlab.contour3d(V, contours=[0]) for i in range(5): time.sleep(1) # Here I'll be computing a new V V = np.random.randn(20, 20, 20) # Update the plot with the new information s.mlab

Combining mayavi and matplotlib in the same figure

﹥>﹥吖頭↗ 提交于 2019-12-07 12:10:27
问题 I will be making animations. In each frame I want to contain both a mayavi plot obtained with mlab.pipeline.iso_surface(source, some other superfluous args) and a matplotlib plot obtained using simply pylab.plot(args) I have scripts to do both separately, but have no idea how to go about combining them into one figure. I want the end product to be one script which contains the code from both the scripts that I currently have. 回答1: AFAIK, there is no direct way because the backends used are so

Constrain Mayavi mouse drag to rotating Earth around its axis

廉价感情. 提交于 2019-12-07 10:10:45
问题 Using iPython Notebook, I have been able to bring up a globe of the Earth with code like: from mayavi import mlab from mayavi.sources.builtin_surface import BuiltinSurface ocean_blue = (0.4, 0.5, 1.0) r = 6371 # km sphere = mlab.points3d(0, 0, 0, name='Globe', scale_mode='none', scale_factor=r * 2.0, color=ocean_blue, resolution=50) sphere.actor.property.specular = 0.20 sphere.actor.property.specular_power = 10 continents_src = BuiltinSurface(source='earth', name='Continents') continents_src

mayavi - setting the [x,y,z] extent of an image programatically

心不动则不痛 提交于 2019-12-07 06:45:50
问题 I have some data that consists of several 2D images that I would like to render in specific [x,y,z] positions relative to one another using mayavi2 (v4.3.0) . From the documentation it seems that I should just be able to do this with mlab.imshow() . Unfortunately, mayavi throws an exception when I call imshow specifying the extent parameter ( AttributeError: 'ImageActor' object has no attribute 'actor' ). I also tried setting the x,y and z data directly by modifying im.mlab_source.x,y,z... .

annotating many points with text in mayavi using mlab

放肆的年华 提交于 2019-12-07 02:24:20
问题 I'm trying to annotate points plotted with the points3d() function using mayavi.mlab. Each point is associated with a label which I would like to plot next to the points using the text3d() function. Plotting the points is fast, however the mlab.text3d() function does not seem to accept arrays of coordinates, so I have to loop over the points and plot the text individually, which is very slow: for i in xrange(0, self.n_labels): self.mlab_data.append( mlab.points3d( pX[self.labels == self.u

Importing mayavi from python creates pop-up with black background on UI (Mavericks/Canopy)

故事扮演 提交于 2019-12-06 15:55:49
问题 Image gallery: http://imgur.com/a/qZkTW#qGj7I0H I just installed the new version of Canopy 1.3 from enthought. I opened up ipython, and I imported mayavi's mlab without issue. I then plotted a 3d sphere without issue using the following: import mayavi from mayavi import mlab mlab.points3d(1,1,1) mlab.show() And I get what I would expect (See figure #2 in gallery). I can then open up the scene editor without issue (see figure #1 in gallery), but when I try to open any other traits editors for

Simple arrow mayavi/tvtk in mlab weird behaviour (looks like a bug)

谁都会走 提交于 2019-12-06 14:46:18
问题 I am trying to do a simple arrow in mlab to point to different areas on the graph. Consider this example: fig = mlab.figure( bgcolor=(0, 0, 0)) b=visual.Box(x=0, y=10, z=10) visual.set_viewer(fig) b=visual.Box(x=0, y=10, z=10) b2=visual.Box(x=10,y=10,z=10, color=(0,0,1)) a=visual.Arrow(x=10,y=10,z=10, color=(1,0,0)) So in my mind the arrow should appear from the blue box, however it lives it's own misterious life and is located absolutely off. That is very strange that boxes are located and

How to draw a color image in mayavi (imshow)

こ雲淡風輕ζ 提交于 2019-12-06 11:24:43
问题 Is it possible to draw a image with 3 color channels using mayavi? According to the documentation for mayavi, mayavi.mlab.imshow can only handle images of shape (n x m). 回答1: Method I had to make use of mayavi's custom colormaps, see http://docs.enthought.com/mayavi/mayavi/auto/example_custom_colormap.html . I made a colormap that consists of all the pixles in the original (n x m x 3) image as rows. I also included an alpha channel so that transparent png's can be displayed correctly. Next I