pl3surf (nverts, xyzverts [, values] [, <keylist>])
pl3surf calls clear3 before putting the plot command on the display list, which means that PyGist can only show one surface at a time using this function. (See pl3tree below for graphs with multiple components).
nc1 = 100 nv1 = nc1 + 1 br = -(nc1 / 2) tr = nc1 / 2 + 1 x = arange (br, tr, typecode = Float) * 40. / nc1 y = arange (br, tr, typecode = Float) * 40. / nc1 z = zeros ( (nv1, nv1), Float) r = sqrt (add. outer ( x ** 2, y ** 2)) + 1e-6 z = sin (r) / r
In order to use pl3surf, we need to construct a mesh using mesh3. The way we shall do that is to define a function on the 3d mesh so that the sombrero function is its 0-isosurface.
z0 = min (ravel (z)) z0 = z0 -.05 * abs (z0) maxz = max (ravel (z)) maxz = maxz + .05 * abs (maxz) zmult = max (max (abs (x)), max (abs (y))) dz = (maxz -z0) nxnynz = array ( [nc1, nc1, 1], Int) dxdydz = array ( [1.0, 1.0, zmult* dz], Float ) x0y0z0 = array ( [float (br), float (br), z0* zmult], Float ) meshf = zeros ( (nv1, nv1, 2), Float ) meshf [:, :, 0] = zmult* z -(x0y0z0 [2]) meshf [:, :, 1] = zmult* z -(x0y0z0 [2] + dxdydz [2])
Finally, we create the mesh and call the plotting functions.
m3 = mesh3 (nxnynz, dxdydz, x0y0z0, funcs = [meshf])
fma ()
# Make sure we don't draw till ready
set_draw3_(0)
pldefault( edges= 0)
[nv, xyzv, col] = slice3 (m3, 1, None, None, value = 0.)
orient3 () # (default orientation)
pl3surf (nv, xyzv)
lim = draw3 (1)
dif = 0.5 * (lim [3] -lim [2])
# dif is used to compress the y scale a bit.
limits (lim [0], lim [1], lim [2] -dif, lim [3] + dif)
palette (" gray. gp")
The graph that results from this sequence of code is on the next page. This next sequence of functions uses slice3mesh to draw the same surface; this time the polygons that make up the surface are colored according to height (using the rainbow palette).
# Try new slicing function to get color graph
[nv, xyzv, col] = slice3mesh (nxnynz [0: 2], dxdydz [0: 2],
x0y0z0 [0: 2], zmult * z, color = zmult * z)
pl3surf (nv, xyzv, values = col)
lim = draw3 (1)
dif = 0.5 * (lim [3] -lim [2])
limits (lim [0], lim [1], lim [2] -dif, lim [3] + dif)
palette (" rainbow. gp")