1
# Copyright (c) 1996, 1997, The Regents of the University of California.
2
# All rights reserved. See Legal.htm for full text and disclaimer.
4
# The following is so I know about arrays:
6
from scipy_base.fastumath import *
7
from shapetest import *
8
from graftypes import *
12
r = Region ( <keyword arguments> ) is used to specify graphing modes
13
for regions in a QuadMesh plot. If a QuadMesh contains one or more
14
Region objects, then a Plotter, when asked to plot it, will plot
15
only the regions specified.
17
The keyword arguments are:
19
number = <integer> the number of the Region being specified.
21
boundary = 0/1 0: plot entire mesh; 1: plot only the boundary of
22
the selected region. if ktype and ltype are not "none",
23
then the boundary will be plotted, then the k and l lines
25
boundary_type, boundary_color: these matter only if boundary = 1,
26
and tell how the boundary will be plotted and what its color
29
inhibit = 0/1/2 1: do not plot the (x [, j], y [, j]) lines;
30
2: do not plot the (x [i, ], y[i, ]) lines.
31
levels = optional two-dimensional sequences of floating point
32
values. If present, a list of the values of z at which you
34
filled = 0/1 If 1, plot a filled mesh using the values of z.
35
If z is not present, the mesh zones will be filled with the
36
background color, which allows plotting of a wire frame.
37
edges, if nonzero when filled=1, draw a solid edge around
39
contours = 0/1 together with filled, controls whether you get
40
filled contours or just contours, or no contours at all.
41
z_scale = "lin", "log", or "normal" as for QuadMesh.
42
vectors = 0/1 allows the user to choose whether or not to
43
plot vx and vy on this region.
44
ktype, ltype: can have the same values as type, and allow the
45
k and l mesh lines to be plotted differently.
46
#### eventually, we can add kcolor, lcolor, kwidth, lwidth ####
47
type, color, width, label, hide, marks, marker as for
54
_RegionSpecError = "RegionSpecError"
56
def __init__ ( self , *kwds , **keywords ) :
59
if not keywords.has_key ( "number" ) :
60
raise _RegionSpecError, "Region number not specified!"
61
self.number = keywords ["number"]
62
if keywords.has_key ("boundary") :
63
self.boundary = keywords ["boundary"]
66
if keywords.has_key ("boundary_type") :
67
self.boundary_type = keywords ["boundary_type"]
69
self.boundary_type = "solid"
70
if keywords.has_key ("boundary_color") :
71
self.boundary_color = keywords ["boundary_color"]
73
self.boundary_color = "fg"
74
if keywords.has_key ("inhibit") :
75
self.inhibit = keywords ["inhibit"]
78
if keywords.has_key ("label") :
79
self.label = keywords ["label"]
82
if keywords.has_key ("hide") :
83
self.hide = keywords ["hide"]
86
if self.boundary == 1 :
87
self.line_type = "none"
89
self.line_type = "solid"
90
if keywords.has_key ("type") :
91
self.line_type = keywords ["type"]
92
if keywords.has_key ("ktype") :
93
self.ktype = keywords ["ktype"]
95
self.ktype = self.line_type
96
if keywords.has_key ("ltype") :
97
self.ltype = keywords ["ltype"]
99
self.ltype = self.line_type
100
if keywords.has_key ("width") :
101
self.width = keywords ["width"]
104
if keywords.has_key ("color") :
105
self.color = keywords ["color"]
108
if keywords.has_key ("filled") :
109
self.filled = keywords ["filled"]
112
if keywords.has_key ("edges") :
113
self.edges = keywords ["edges"]
116
if keywords.has_key ("vectors") :
117
self.vectors = keywords ["vectors"]
120
if keywords.has_key ("contours") :
121
self.contours = keywords ["contours"]
122
elif self.filled == 0 and self.edges == 0 and self.vectors == 0 :
126
if keywords.has_key ("z_scale") :
127
self.z_scale = keywords ["z_scale"]
130
if keywords.has_key ("ewidth") :
131
self.ewidth = keywords ["ewidth"]
134
if keywords.has_key ("ecolor") :
135
self.ecolor = keywords ["ecolor"]
138
if keywords.has_key ("levels") :
139
self.levels = keywords ["levels"]
142
if keywords.has_key ("marks") :
143
self.marks = keywords ["marks"]
146
if keywords.has_key ( "marker" ) :
147
self.marker = keywords [ "marker" ]
149
self.marker = "unspecified"
151
def new ( self, ** keywords ) :
152
""" new (...keyword arguments...) allows you to reuse a
153
previously existing Region.
155
self.__init__ ( keywords )
157
def set ( self , ** keywords ) :
158
""" set (...keyword arguments...) allows you to set individual
159
Region characteristics. No error checking is done.
161
for k in keywords.keys ():
163
self.line_type = keywords ["type"]
165
setattr (self, k, keywords [k])