@@ -24,8 +24,6 @@ def plot(atoms, data, contours):
24
24
25
25
# Delay slow imports:
26
26
from mayavi import mlab
27
- from tvtk .api import tvtk
28
- import mayavi .tools .pipeline
29
27
30
28
mlab .figure (1 , bgcolor = (1 , 1 , 1 )) # make a white figure
31
29
@@ -38,7 +36,6 @@ def plot(atoms, data, contours):
38
36
39
37
# Draw the unit cell:
40
38
A = atoms .cell
41
- print ('A=%s' % str (A ))
42
39
for i1 , a in enumerate (A ):
43
40
i2 = (i1 + 1 ) % 3
44
41
i3 = (i1 + 2 ) % 3
@@ -51,17 +48,18 @@ def plot(atoms, data, contours):
51
48
[p1 [2 ], p2 [2 ]],
52
49
tube_radius = 0.1 )
53
50
54
- cp = mlab .contour3d (data , contours = contours )
55
- # Do some tvtk magic in order to allow for non-orthogonal unit cells
51
+ cp = mlab .contour3d (data , contours = contours , transparent = True ,
52
+ opacity = 0.5 , colormap = 'hot' )
53
+ # Do some tvtk magic in order to allow for non-orthogonal unit cells:
56
54
polydata = cp .actor .actors [0 ].mapper .input
57
- pts = np .array (polydata .points )
58
- # Transform the points to the unit cell
59
- polydata .points = np .dot (pts , A / data .shape )
55
+ pts = np .array (polydata .points ) - 1
56
+ # Transform the points to the unit cell:
57
+ polydata .points = np .dot (pts , A / np . array ( data .shape )[:, np . newaxis ] )
60
58
61
59
# Apparently we need this to redraw the figure, maybe it can be done in
62
60
# another way?
63
61
mlab .view (azimuth = 155 , elevation = 70 , distance = 'auto' )
64
- # Show the 3d plot
62
+ # Show the 3d plot:
65
63
mlab .show ()
66
64
67
65
0 commit comments