19
19
.. function:: imshow(*args, **kwargs)
22
Allows one to view a 2D Numeric array as an image. This works
23
best for very large arrays (like 1024x1024 arrays).
22
View a 2D array as an image.
25
24
**Function signatures**::
28
s is a 2 dimension array. The values of s are mapped to a color using
29
31
**Keyword arguments:**
41
43
:figure: Figure to populate.
45
:interpolate: if the pixels in the image are to be
46
interpolated or not. Must be a boolean. Default: True
43
48
:line_width: The with of the lines, if any used. Must be a float.
46
51
:name: the name of the vtk object created.
48
:opacity: The overall opacity of the vtk object. Must be a float.
51
:representation: the representation type used for the surface. Must be
52
'surface' or 'wireframe' or 'points'. Default:
53
:opacity: the opacity of the image. Must be a legal value. Default:
55
56
:transparent: make the opacity of the actor depend on the
99
100
quiver3d(x, y, z, u, v, w, ...)
100
101
quiver3d(x, y, z, f, ...)
102
If only 3 arrays u, v, w are passed the x, y and z arrays are assumed to be
103
made from the indices of vectors.
105
If 4 positional arguments are passed the last one must be a callable, f,
106
that returns vectors.
103
u, v, w are numpy arrays giving the components of the vectors.
105
If only 3 arrays, u, v, and w are passed, they must be 3D arrays, and
106
the positions of the arrows are assumed to be the indices of the
107
corresponding points in the (u, v, w) arrays.
109
If 6 arrays, (x, y, z, u, v, w) are passed, the 3 first arrays give
110
the position of the arrows, and the 3 last the components. They
113
If 4 positional arguments, (x, y, z, f) are passed, the last one must be
114
a callable, f, that returns vectors components (u, v, w) given the
108
117
**Keyword arguments:**
145
154
:scalars: optional scalar data.
147
:scale_factor: the scaling applied to the glyphs. The
148
size of the glyph is by default in drawing
149
units. Must be a float. Default: 1.0
156
:scale_factor: The scaling applied to the glyphs. the simple of the
157
glyph is by default calculated from the inter-glyph
158
spacing. Specify a float to give the maximum glyph size
151
161
:scale_mode: the scaling mode for the glyphs
152
162
('vector', 'scalar', or 'none').
174
184
from enthought.mayavi.mlab import *
176
186
def test_quiver3d():
178
xmin, xmax, ymin, ymax, zmin, zmax = [-5,5,-5,5,-5,5]
179
x, y, z = numpy.mgrid[xmin:xmax:dims[0]*1j,
180
ymin:ymax:dims[1]*1j,
181
zmin:zmax:dims[2]*1j]
192
obj = quiver3d(x, y, z, u, v, w, mode='cone', extent=(0,1, 0,1, 0,1),
187
x, y, z = numpy.mgrid[-2:3, -2:3, -2:3]
188
r = numpy.sqrt(x**2 + y**2 + z**4)
189
u = y*numpy.sin(r)/(r+0.001)
190
v = -x*numpy.sin(r)/(r+0.001)
191
w = numpy.zeros_like(z)
192
obj = quiver3d(x, y, z, u, v, w, line_width=3, scale_factor=1)
211
209
plot3d(x, y, z, ...)
212
210
plot3d(x, y, z, s, ...)
212
x, y, z and s are numpy arrays or lists of the same shape. x, y and z
213
give the positions of the successive points of the line. s is an
214
optional scalar value associated with each point.
214
216
**Keyword arguments:**
216
218
:color: the color of the vtk object. Overides the colormap,
270
272
n_mer, n_long = 6, 11
273
phi = numpy.arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')
275
phi = numpy.arange(0.0, 2*pi + 0.5*dphi, dphi)
275
277
x = numpy.cos(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
276
278
y = numpy.sin(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
289
291
.. function:: surf(*args, **kwargs)
292
Plots a surface using regularly spaced elevation data supplied as a 2D
294
Plots a surface using regularly-spaced elevation data supplied as a 2D
295
297
**Function signatures**::
298
300
surf(x, y, s, ...)
299
301
surf(x, y, f, ...)
301
If 3 positional arguments are passed the last one must be an array s,
302
or a callable, f, that returns an array. x and y give the
303
coordinnates of positions corresponding to the s values.
305
z is the elevation matrix.
303
s is the elevation matrix, a 2D array.
307
305
x and y can be 1D or 2D arrays (such as returned by numpy.ogrid or
308
306
numpy.mgrid), but the points should be located on an orthogonal grid
311
309
arbitrary-shaped position arrays (non-orthogonal grids), see the mesh
314
If only 1 array s is passed the x and y arrays are assumed to be
312
If only 1 array s is passed, the x and y arrays are assumed to be
315
313
made from the indices of arrays, and an uniformly-spaced data set is
316
If 3 positional arguments are passed the last one must be an array s,
317
or a callable, f, that returns an array. x and y give the
318
coordinnates of positions corresponding to the s values.
318
320
**Keyword arguments:**
320
322
:color: the color of the vtk object. Overides the colormap,
407
409
mesh(x, y, z, ...)
409
x, y, z are 2D arrays giving the positions of the vertices of the surface.
410
The connectivity between these points is implied by the connectivity on
411
x, y, z are 2D arrays, all of the same shape, giving the positions of
412
the vertices of the surface. The connectivity between these points is
413
implied by the connectivity on the arrays.
413
415
For simple structures (such as orthogonal grids) prefer the surf function,
414
416
as it will create more efficient data structures.
417
418
**Keyword arguments:**
419
420
:color: the color of the vtk object. Overides the colormap,
525
526
**Function signatures**::
527
528
contour3d(scalars, ...)
528
contour3d(scalarfield, ...)
529
contour3d(x, y, z, scalars, ...)
531
scalars is a 3D numpy arrays giving the data on a grid.
533
If 4 arrays, (x, y, z, scalars) are passed, the 3 first arrays give
534
the position of the arrows, and the last the scalar value. The x, y
535
and z arrays are then supposed to have been generated by
536
`numpy.mgrid`, in other words, they are 3D arrays, with positions
537
lying on a 3D orthogonal and regularily spaced grid with nearest
538
neighboor in space matching nearest neighboor in the array. The
539
function builds a scalar field assuming the points are regularily
542
If 4 positional arguments, (x, y, z, f) are passed, the last one
543
can also be a callable, f, that returns vectors components (u, v, w)
544
given the positions (x, y, z).
530
546
**Keyword arguments:**
577
593
from enthought.mayavi.mlab import *
579
595
def test_contour3d():
581
xmin, xmax, ymin, ymax, zmin, zmax = [-5,5,-5,5,-5,5]
582
x, y, z = numpy.ogrid[xmin:xmax:dims[0]*1j,
583
ymin:ymax:dims[1]*1j,
584
zmin:zmax:dims[2]*1j]
596
x, y, z = numpy.ogrid[-5:5:64j, -5:5:64j, -5:5:64j]
590
598
scalars = x*x*0.5 + y*y + z*z*2.0
592
600
obj = contour3d(scalars, contours=4, transparent=True)
607
615
**Function signatures**::
609
points3d(scalardata, ...)
610
617
points3d(x, y, z...)
611
618
points3d(x, y, z, s, ...)
612
619
points3d(x, y, z, f, ...)
614
If only one positional argument is passed, it should be VTK data
615
object with scalar data.
617
If only 3 arrays x, y, z all the points are drawn with the same size
620
If 4 positional arguments are passed the last one can be an array s
621
or a callable f that gives the size and color of the glyph.
621
x, y and z are numpy arrays, or lists, all of the same shape, giving
622
the positions of the points.
624
If only 3 arrays x, y, z are given, all the points are drawn with the
627
In addition, you can pass a fourth array s of the same
628
shape as x, y, and z giving an associated scalar value for each
629
point, or a function f(x, y, z) returning the scalar value. This
630
scalar value can be used to modulate the color and the size of the
623
633
**Keyword arguments:**
657
667
instance, this is the number of divisions along theta and
658
668
phi. Must be an integer. Default: 8
660
:scale_factor: the scaling applied to the glyphs. The
661
size of the glyph is by default in drawing
662
units. Must be a float. Default: 1.0
670
:scale_factor: The scaling applied to the glyphs. the simple of the
671
glyph is by default calculated from the inter-glyph
672
spacing. Specify a float to give the maximum glyph size
664
675
:scale_mode: the scaling mode for the glyphs
665
676
('vector', 'scalar', or 'none').
708
719
.. function:: flow(*args, **kwargs)
711
Creates streamlines following the flow of a vector field.
722
Creates trajectories of particles following the flow of a vector field.
713
724
**Function signatures**::
716
727
flow(x, y, z, u, v, w, ...)
717
728
flow(x, y, z, f, ...)
719
If only 3 arrays u, v, w are passed the x, y and z arrays are assumed to be
720
made from the indices of vectors.
722
If the x, y and z arrays are passed they are supposed to have been
723
generated by `numpy.mgrid`. The function builds a scalar field assuming
724
the points are regularily spaced.
726
If 4 positional arguments are passed the last one must be a callable, f,
727
that returns vectors.
730
u, v, w are numpy arrays giving the components of the vectors.
732
If only 3 arrays, u, v, and w are passed, they must be 3D arrays, and
733
the positions of the arrows are assumed to be the indices of the
734
corresponding points in the (u, v, w) arrays.
736
If 6 arrays, (x, y, z, u, v, w) are passed, the 3 first arrays give
737
the position of the arrows, and the 3 last the components. The x, y
738
and z arrays are then supposed to have been generated by
739
`numpy.mgrid`, in other words, they are 3D arrays, with positions
740
lying on a 3D orthogonal and regularily spaced grid with nearest
741
neighboor in space matching nearest neighboor in the array. The
742
function builds a vector field assuming the points are regularily
745
If 4 positional arguments, (x, y, z, f) are passed, the last one must be
746
a callable, f, that returns vectors components (u, v, w) given the
729
749
**Keyword arguments:**
793
813
from enthought.mayavi.mlab import *
797
xmin, xmax, ymin, ymax, zmin, zmax = [-5,5,-5,5,-5,5]
798
x, y, z = numpy.mgrid[xmin:xmax:dims[0]*1j,
799
ymin:ymax:dims[1]*1j,
800
zmin:zmax:dims[2]*1j]
811
obj = flow(x, y, z, u, v, w, linetype='tube')
816
x, y, z = numpy.mgrid[0:5, 0:5, 0:5]
817
r = numpy.sqrt(x**2 + y**2 + z**4)
819
v = -x*numpy.sin(r)/r
820
w = numpy.zeros_like(z)
821
831
.. function:: contour_surf(*args, **kwargs)
824
Plots a the contours of asurface using grid spaced data supplied as 2D
834
Plots a the contours of a surface using grid-spaced data for
835
elevation supplied as a 2D array.
827
837
**Function signatures**::
830
840
contour_surf(x, y, s, ...)
831
841
contour_surf(x, y, f, ...)
833
If only one array s is passed the x and y arrays are assumed to be made
835
s is the elevation matrix.
843
s is the elevation matrix, a 2D array. The contour lines plotted
844
are lines of equal s value.
846
x and y can be 1D or 2D arrays (such as returned by numpy.ogrid or
847
numpy.mgrid), but the points should be located on an orthogonal grid
848
(possibly non-uniform). In other words, all the points sharing a same
849
index in the s array need to have the same x or y value. For
850
arbitrary-shaped position arrays (non-orthogonal grids), see the mesh
853
If only 1 array s is passed, the x and y arrays are assumed to be
854
made from the indices of arrays, and an uniformly-spaced data set is
857
If 3 positional arguments are passed the last one must be an array s,
858
or a callable, f, that returns an array. x and y give the
859
coordinnates of positions corresponding to the s values.
837
861
**Keyword arguments:**
919
943
barchart(x, y, z, s, ...)
920
944
barchart(x, y, z, f, ...)
922
If only one positional argument is passed, it can be a 1D, 2D, or 3D
946
If only one positional argument is passed, it can be a 1-D, 2-D, or 3-D
923
947
array giving the length of the vectors. The positions of the data
924
948
points are deducted from the indices of array, and an
925
949
uniformly-spaced data set is created.
1024
1048
**Function signatures**::
1026
mesh(x, y, z, triangles ...)
1050
triangular_mesh(x, y, z, triangles ...)
1028
1052
x, y, z are arrays giving the positions of the vertices of the surface.
1029
1053
triangles is a list of triplets (or an array) list the vertices in