~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/region.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 1996, 1997, The Regents of the University of California.
 
2
# All rights reserved.  See Legal.htm for full text and disclaimer.
 
3
 
 
4
# The following is so I know about arrays:
 
5
from Numeric import *
 
6
from scipy_base.fastumath import *
 
7
from shapetest import *
 
8
from graftypes import *
 
9
 
 
10
class Region :
 
11
   """
 
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.
 
16
 
 
17
   The keyword arguments are:
 
18
 
 
19
      number = <integer> the number of the Region being specified.
 
20
 
 
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
 
24
       with their own types.
 
25
      boundary_type, boundary_color: these matter only if boundary = 1,
 
26
       and tell how the boundary will be plotted and what its color
 
27
       will be.
 
28
 
 
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
 
33
        want contours.
 
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
 
38
        each zone.
 
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
 
48
        curves.
 
49
   """
 
50
 
 
51
   def type (self) :
 
52
       return RegionType
 
53
 
 
54
   _RegionSpecError = "RegionSpecError"
 
55
 
 
56
   def __init__ ( self , *kwds , **keywords ) :
 
57
       if len (kwds) == 1 :
 
58
          keywords = kwds[0]
 
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"]
 
64
       else :
 
65
          self.boundary = 0
 
66
       if keywords.has_key ("boundary_type") :
 
67
          self.boundary_type = keywords ["boundary_type"]
 
68
       else :
 
69
          self.boundary_type = "solid"
 
70
       if keywords.has_key ("boundary_color") :
 
71
          self.boundary_color = keywords ["boundary_color"]
 
72
       else :
 
73
          self.boundary_color = "fg"
 
74
       if keywords.has_key ("inhibit") :
 
75
          self.inhibit = keywords ["inhibit"]
 
76
       else :
 
77
          self.inhibit = 0
 
78
       if keywords.has_key ("label") :
 
79
          self.label = keywords ["label"]
 
80
       else :
 
81
          self.label = " "
 
82
       if keywords.has_key ("hide") :
 
83
          self.hide = keywords ["hide"]
 
84
       else :
 
85
          self.hide = 0
 
86
       if self.boundary == 1 :
 
87
          self.line_type = "none"
 
88
       else :
 
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"]
 
94
       else :
 
95
          self.ktype = self.line_type
 
96
       if keywords.has_key ("ltype") :
 
97
          self.ltype = keywords ["ltype"]
 
98
       else :
 
99
          self.ltype = self.line_type
 
100
       if keywords.has_key ("width") :
 
101
          self.width = keywords ["width"]
 
102
       else :
 
103
          self.width = 1
 
104
       if keywords.has_key ("color") :
 
105
          self.color = keywords ["color"]
 
106
       else :
 
107
          self.color = "fg"
 
108
       if keywords.has_key ("filled") :
 
109
          self.filled = keywords ["filled"]
 
110
       else :
 
111
          self.filled = 0
 
112
       if keywords.has_key ("edges") :
 
113
          self.edges = keywords ["edges"]
 
114
       else :
 
115
          self.edges = 0
 
116
       if keywords.has_key ("vectors") :
 
117
          self.vectors = keywords ["vectors"]
 
118
       else :
 
119
          self.vectors = 1
 
120
       if keywords.has_key ("contours") :
 
121
          self.contours = keywords ["contours"]
 
122
       elif self.filled == 0 and self.edges == 0 and self.vectors == 0 :
 
123
          self.contours = 1
 
124
       else :
 
125
          self.contours = 0
 
126
       if keywords.has_key ("z_scale") :
 
127
          self.z_scale = keywords ["z_scale"]
 
128
       else :
 
129
          self.z_scale = "lin"
 
130
       if keywords.has_key ("ewidth") :
 
131
          self.ewidth = keywords ["ewidth"]
 
132
       else :
 
133
          self.ewidth = 1
 
134
       if keywords.has_key ("ecolor") :
 
135
          self.ecolor = keywords ["ecolor"]
 
136
       else :
 
137
          self.ecolor = "fg"
 
138
       if keywords.has_key ("levels") :
 
139
          self.levels = keywords ["levels"]
 
140
       else :
 
141
          self.levels = None
 
142
       if keywords.has_key ("marks") :
 
143
          self.marks = keywords ["marks"]
 
144
       else :
 
145
          self.marks = 0
 
146
       if keywords.has_key ( "marker" ) :
 
147
          self.marker = keywords [ "marker" ]
 
148
       else :
 
149
          self.marker = "unspecified"
 
150
 
 
151
   def new ( self, ** keywords ) :
 
152
       """ new (...keyword arguments...) allows you to reuse a
 
153
       previously existing Region.
 
154
       """
 
155
       self.__init__ ( keywords )
 
156
 
 
157
   def set ( self , ** keywords ) :
 
158
       """ set (...keyword arguments...) allows you to set individual
 
159
       Region characteristics. No error checking is done.
 
160
       """
 
161
       for k in keywords.keys ():
 
162
           if k == "type" :
 
163
              self.line_type = keywords ["type"]
 
164
           else :
 
165
              setattr (self, k, keywords [k])