[Top] [Prev] [Next] [Bottom]

3.4 Region Objects

Currently only PyGist supports Regions.


from region import *
rg = Region ( <keylist>)


Region objects are used to specify graphing modes for some or all of the regions in a QuadMesh plot. As we shall show in the examples later in this section, subsets of the regions in a QuadMesh can be selected for plotting, and different regions can be plotted with different keyword options. The QuadMesh keyword regions is used to specify a list of Region objects to a QuadMesh. If such a list of Region objects is given, then only those regions on the list will be plotted, even though the QuadMesh may contain others.

The keywords arguments recognized are:

number, boundary, boundary_type, boundary_color, inhibit, levels, filled, contours, vectors, z_scale, edges, type, color, width, label, hide, marks, marker

Note that there are no keywords for specifying the mesh itself. Regions are never plotted unless they belong to an already-defined QuadMesh, which has all the necessary information.

Region, like other 2d classes, also has the methods set and new.

Keyword Arguments

The keyword arguments for Region object instantiation are as follows:

number = <positive integer>: the number of the Region being specified. must correspond to one or more entries in the ireg array of the QuadMesh to which this Region belongs.
boundary = 0/1--0: plot portion of mesh for the selected region; 1: plot only the boundary of the selected region.
boundary_type, boundary_color: these matter only if boundary = 1, and tell how the boundary will be plotted and what its color will be.
inhibit = 0/1/2--0: plot both sets of mesh lines; 1: do not plot the (x [:, j], y [, j]) lines; 2: do not plot the (x [i,:], y[i,:]) lines; 3: if boundary = 1, do not plot the boundary (default 0). Only applies if edges = 1.
levels = either:
(1) optional one-dimensional sequence of floating point values. If present, a list of the values of z at which you want contours; or
(2) a single integer specifying the number of contours, in which case the graphics will compute the contour levels.
filled = 0/1--If 1, plot a filled mesh using the values of z if contours = 0, or plot filled contours if contours = 1 (this option is not available at the time of writing of this manual, but will be added soon). If z is not present, the mesh zones will be filled with the background color, which allows plotting of a wire frame. (default value: 0.)
contours = 0/1--if 1, contours will be plotted if filled = 0, and filled contours will be plotted if filled = 1 (this option is not available at the time of writing of this manual, but will be added soon). contours normally defaults to 0, but will default to 1 if edges = 0, filled = 0, and vectors = 0 on the theory that you must want to plot something.
The user should Table 3, "filled and contours," on page 23 to understand how these last two parameters relate.
z_scale = "lin" (default), "log", or "normal" specifies how the contours are to be computed.
vectors = 0/1--This keyword is only meaningful if the QuadMesh containing this Region has the vectors vx and vy defined. If 0, the vectors defined on this Region will not be plotted; if 1, they will be. (default: 1)
edges, if nonzero when filled = 1, draw a solid edge around each zone, as controlled by keyword inhibit. ewidth and ecolor may also be used.
type, color, width, label, hide, marks, marker as for QuadMesh. Remember that a marker specified for a contour plot represents the first of a consecutive series of markers for the contours.

Methods new and set are as in the Curve and QuadMesh classes. Remember to beware of setting conflicting values for keywords with set.


The following examples illustrate (on the same mesh as before) how you can plot the regions of the mesh in differing styles. Study the code and comments carefully, and run the examples yourself.

from region import *
# Region 1 will have a solid, foreground-colored boundary:
r1 = Region (number = 1, width = 1., color = "fg",
boundary = 1)
# Region 2 will be plotted with no boundary and with its
# mesh lines colored green and dashed in appearance:
r2 = Region (number = 2, width = 1., color = "green",
type = "dash")
# Region 3 will be plotted in the same style as Region 1:
r3 = Region (number = 3, width = 1., color = "fg",
boundary = 1)
# We now send the region list to the existing QuadMesh qm:
qm.set (regions = [r1, r2, r3])
# Change the graph to print Region 2 in red on top
# of Region 2, then plot the graph:
gr.change(text = "Region 2", text_pos = [0.25,0.54],
text_size = 18, text_color = "red")
gr.plot ()
# The next plot will be a vector plot, so send vectors
# to the QuadMesh qm:
qm.set (vx = vt, vy = ut, scale = 1.)
# Plot r1's vectors in red:
r1.set (color = "red")
# Change the color of r2's mesh to foreground, and
# give it a solid boundary. Its vectors will also be
# foreground.
r2.set (color = "fg", type = "solid", boundary = 1)
# Suppress the plotting of vectors over r3
r3.set (vectors = 0)
# Erase the text and plot:
gr.change(text = "")
gr.plot ()
# Change qm back to the rectangular mesh, and change
# the vector field:
qm.set(z = z, x = xr, y = yr, vx = xr + yr/5.,
vy = yr + xr/10., scale = .05)
# change r1 to have orange vectors:
r1.set (color = "orange", width = 3.)
# r2 will have red contours, no vectors:
r2.set (color = "red", width = 3., vectors = 0,
contours = 1, type = "solid", levels = 20)
# r3 will have cyan colored vectors:
r3.set (color = "cyan", width = 3., vectors = 1)
gr.plot ()

[Top] [Prev] [Next] [Bottom]

Copyright © 1997,Regents of the University of California. All rights reserved.