/[escript]/trunk/pyvisi/py_src/renderers/gnuplot/plot.py
ViewVC logotype

Contents of /trunk/pyvisi/py_src/renderers/gnuplot/plot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 605 - (show annotations)
Mon Mar 20 07:16:27 2006 UTC (13 years, 7 months ago) by gross
File MIME type: text/x-python
File size: 5600 byte(s)
pyvisi with vtk runs noe on the altix
1 # Copyright (C) 2004-2005 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: plot.py,v 1.61 2005/11/30 04:28:30 paultcochrane Exp $
18
19 """
20 Class and functions associated with a pyvisi Plot objects (gnuplot)
21 """
22
23 # generic imports
24 from common import debugMsg
25 import copy
26
27 # module specific imports
28 from item import Item
29
30 __revision__ = '$Revision: 1.61 $'
31
32 class Plot(Item):
33 """
34 Abstract plot class
35 """
36 def __init__(self, scene):
37 """
38 Initialisation of abstract Plot class
39
40 @param scene: the scene with which to associate the Plot
41 @type scene: Scene object
42 """
43 debugMsg("Called Plot.__init__()")
44 Item.__init__(self)
45
46 self.renderer = scene.renderer
47
48 self.title = None
49 self.xlabel = None
50 self.ylabel = None
51 self.zlabel = None
52
53 if scene is None:
54 raise ValueError, "You must specify a scene object"
55
56 def setData(self, *dataList):
57 """
58 Set data to Plot
59
60 @param dataList: the data to set to the plot (should be an array or list
61 or something)
62 @type dataList: tuple
63 """
64 debugMsg("Called Plot.setData()")
65
66 if dataList is None:
67 raise ValueError, "You must specify a data list"
68
69 return
70
71 def setTitle(self, title):
72 """
73 Set the plot title
74
75 @param title: the string holding the title to the plot
76 @type title: string
77 """
78 debugMsg("Called Plot.setTitle()")
79
80 self.title = title
81
82 return
83
84 def setXLabel(self, label):
85 """
86 Set the label of the x-axis
87
88 @param label: the string holding the label of the x-axis
89 @type label: string
90 """
91 debugMsg("Called Plot.setXLabel()")
92
93 self.xlabel = label
94
95 return
96
97 def setYLabel(self, label):
98 """
99 Set the label of the y-axis
100
101 @param label: the string holding the label of the y-axis
102 @type label: string
103 """
104 debugMsg("Called Plot.setYLabel()")
105
106 self.ylabel = label
107
108 return
109
110 def setZLabel(self, label):
111 """
112 Set the label of the z-axis
113
114 @param label: the string holding the label of the z-axis
115 @type label: string
116 """
117 debugMsg("Called Plot.setZLabel()")
118
119 self.zlabel = label
120
121 return
122
123 def setLabel(self, axis, label):
124 """
125 Set the label of a given axis
126
127 @param axis: string (Axis object maybe??) of the axis (e.g. x, y, z)
128
129 @param label: string of the label to set for the axis
130 @type label: string
131 """
132 debugMsg("Called Plot.setLabel()")
133
134 # string-wise implementation (really budget implementation too)
135 if axis == 'x' or axis == 'X':
136 self.xlabel = label
137 elif axis == 'y' or axis == 'Y':
138 self.ylabel = label
139 elif axis == 'z' or axis == 'Z':
140 self.zlabel = label
141 else:
142 raise ValueError, "axis must be x or y or z"
143
144 return
145
146 def setXAxisRange(self, xMin, xMax):
147 """
148 Set the range of the x axis
149
150 @param xMin: the minimum value of the x-axis
151 @type xMin: float
152
153 @param xMax: the maximum value of the x-axis
154 @type xMax: float
155 """
156 debugMsg("Called Plot.setXAxisRange()")
157
158 # check that the max is (strictly) bigger than the min
159 if (xMax <= xMin):
160 raise ValueError, "xMax should be strictly greater than xMin"
161
162 evalString = "_gnuplot('set xrange [%f:%f]')" % (xMin, xMax)
163 self.renderer.runString(evalString)
164
165 return
166
167 def setYAxisRange(self, yMin, yMax):
168 """
169 Set the range of the y axis
170
171 @param yMin: the minimum value of the y-axis
172 @type yMin: float
173
174 @param yMax: the maximum value of the y-axis
175 @type yMax: float
176 """
177 debugMsg("Called Plot.setYAxisRange()")
178
179 # check that the max is (strictly) bigger than the min
180 if (yMax <= yMin):
181 raise ValueError, "yMax should be strictly greater than yMin"
182
183 evalString = "_gnuplot('set yrange [%f:%f]')" % (yMin, yMax)
184 self.renderer.runString(evalString)
185
186 return
187
188 def setZAxisRange(self, zMin, zMax):
189 """
190 Set the range of the z axis
191
192 @param zMin: the minimum value of the z-axis
193 @type zMin: float
194
195 @param zMax: the maximum value of the z-axis
196 @type zMax: float
197 """
198 debugMsg("Called Plot.setZAxisRange()")
199
200 # check that the max is (strictly) bigger than the min
201 if (zMax <= zMin):
202 raise ValueError, "zMax should be strictly greater than zMin"
203
204 evalString = "_gnuplot('set zrange [%f:%f])" % (zMin, zMax)
205 self.renderer.runString(evalString)
206
207 return
208
209 # vim: expandtab shiftwidth=4:
210

  ViewVC Help
Powered by ViewVC 1.1.26