mayavi

locking camera in mayavi

偶尔善良 提交于 2019-12-05 04:23:57
I'm trying to make an animation with a sequence of datafiles in mayavi. Unfortunately i have noticed that camera doesn't lock (it is zooming and zooming out). I think it is happening because the Z componrnt of my mesh is changing and mayavi is trying to recalculate scales. How can I fix it? import numpy from mayavi import mlab mlab.figure(size = (1024,768),bgcolor = (1,1,1)) mlab.view(azimuth=45, elevation=60, distance=0.01, focalpoint=(0,0,0)) #mlab.move(forward=23, right=32, up=12) for i in range(8240,8243): n=numpy.arange(10,400,20) k=numpy.arange(10,400,20) [x,y] = numpy.meshgrid(k,n) z

Mayavi: rotate around y axis

感情迁移 提交于 2019-12-05 01:57:09
I'm plotting a 3D mesh using mayavi's triangular_mesh method. The data describes a human silhouette laying face-down in 3D space (so the cmap can be used to denote distance from the camera). Here's the code used to generate the plot (the faces and vertices come from an external object, and there are far too many to show here): from mayavi import mlab import math import numpy as np import sys import os fig = mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1), size=(1920, 980)) a = np.array(this_mesh.vertices - refC.conj().transpose()) # this_mesh is an object created from external data files this

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

送分小仙女□ 提交于 2019-12-04 22:19:26
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 anything else, I get a weird black background with no text: scalarscatter editor This issue affects all

How to display a volume with non-cubic voxels correctly in mayavi

只谈情不闲聊 提交于 2019-12-04 20:00:01
问题 I'm using mayavi (3.3.2) to display volume isosurfaces. Generally, my volumes do not have cubic voxels; for example, the sampling grid might be 1mm x 1mm in X and Y, but 1.4mm in the Z direction. How can I get such volumes to display with the correct spatial proportions using mayavi's mlab.contour3d or mlab.pipeline.iso_surface ? I'd really prefer to not resample the volumes to a cubic grid. Another way of stating the problem: what can I do to get the below code to display a sphere instead of

Phong shading for shiny Python 3D surface plots

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 18:37:19
问题 I'm trying to create aesthetically pleasing 3D plots in Python with specular shading, and thus far have tried using both Matplotlib with 3D axes and surface plots from Mayavi, e.g., from the Mayavi surf examples web page: The results look good, and in Mayavi there does seem to be reasonable control of the lighting, although I can't seem to achieve a "shiny" appearance. In Matlab, this can be achieved by using 'Phong' lighting: see http://www.mathworks.com/matlabcentral/fileexchange/35240

How to plot proper 3D axes in MayaVi, like those found in Matplotlib

↘锁芯ラ 提交于 2019-12-04 18:32:28
问题 I would like to know how to have proper axes on a 3D surface plot in MayaVi. The best axes I could create looked something like this... However, these do not look very professional if I were to give a presentation or put these on a poster. I would like the axes to look something like this... These axes look much more professional and are easier to read than the default MayaVi axes. Any help would be greatly appreciated. Thanks! 回答1: I had this problem too. I hacked a bad workaround by not

Using TraitsUI in Mayavi to create a GUI, magnetic field simulation

末鹿安然 提交于 2019-12-04 16:46:55
I am currently working on a project that I have to simulate the magnetic field produced by a circular wire loop. I have written a piece of code and put it into a class, that works perfectly, but when I try to create a GUI using TaitsUI, it just fails. I have no idea how should I connect the one to the other. class Wireloop: x,y,z = np.mgrid[-10:10:150j, -10:10:150j, -10:10:150j] ### Transform to Cylindrial Polar r = np.sqrt(x**2 + y**2) # ρ in polar x_trans = x/r # cos(θ) y_trans = y/r # sin(θ) """ """ def __init__(self, R, I): self.R = R #radious self.I = I #DC current #Constants self.mew0 =

How to draw a color image in mayavi (imshow)

一曲冷凌霜 提交于 2019-12-04 15:35:00
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). 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 used a grayscale image as a lookup table, with pixle values as indices to the original pixles stored in the

Disable or Catch VTK warnings in vtkOutputWindow when embedding Mayavi

江枫思渺然 提交于 2019-12-04 05:23:23
I'd like to either disable the VTK warning window or, better yet, catch them to handle with my application's logging system. My application is using an embedded mayavi view, and I don't want error windows popping up that I have no control over. The following code demonstrates the warning window. import numpy as np from mayavi import mlab x1 = np.array([1, 1, 2, 3]) y1 = np.array([1, 1, 4, 2]) z1 = np.array([1, 1, 5, 1]) mlab.plot3d(x1, y1, z1) mlab.show() Ok, I've done some research and discovered that vtk.vtkObject.GlobalWarningDisplayOff() will disable the window completely, which is nice.

How to install Mayavi Trait backends?

半城伤御伤魂 提交于 2019-12-04 03:04:25
OS: Linux Kubuntu 14.4.5 Python: Python 3.5.2 :: Continuum Analytics, Inc. I tried to install Mayavi into my anaconda environment: conda install -c menpo mayavi=4.5.0 conda install -c anaconda wxpython=3.0.0.0 conda install pyqt conda install qt But when I try to run the example from http://docs.enthought.com/mayavi/mayavi/auto/example_surface_from_irregular_data.html I get the error message ImportError: Could not import backend for traits with the explanation: Make sure that you have either the TraitsBackendWx or the TraitsBackendQt projects installed. If you installed Mayavi with easy