Changeset 13118 for fact/tools/pyscripts/pyfact
- Timestamp:
- 03/15/12 13:43:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/plotters.py
r13100 r13118 10 10 import os.path 11 11 import sys 12 13 # this class was formerly called Plotter in the depricated 14 # module plotter.py 15 class SimplePlotter(object): 16 """ simple x-y plot """ 17 def __init__(self, name, x, style = 'b', xlabel='x', ylabel='y'): 18 """ initialize the object """ 19 20 self.name = name 21 self.fig = plt.figure() 22 self.line, = plt.plot(x, style) 23 24 plt.title(name) 25 plt.xlabel(xlabel) 26 plt.ylabel(ylabel) 27 plt.grid(True) 28 29 def __call__(self, ydata): 30 """ set ydata of plot """ 31 plt.figure(self.fig.number) 32 plt.ylim( np.min(ydata), np.max(ydata) ) 33 self.line.set_ydata(ydata) 34 plt.draw() 35 36 def _test_SimplePlotter(): 37 """ test of maintaining two independant plotter instances """ 38 plt.ion() 39 40 x = np.linspace(0., 10.) 41 plot1 = SimplePlotter('plot1', x, 'r') 42 print 'plot1.fig.number: ', plot1.fig.number 43 plot2 = SimplePlotter('plot2', x, 'g.') 44 print 'plot2.fig.number: ', plot2.fig.number 45 46 plot1(np.sin(x) * 7.) 47 plot2(x*x) 48 49 raw_input('next') 50 51 plot1(np.cos(x) * 3.) 52 plot2(x) 53 54 raw_input('next') 55 12 56 13 57 class Plotter(object): … … 340 384 if __name__ == '__main__': 341 385 """ test the class """ 342 #_test_Plotter() 386 print ' testing SimplePlotter' 387 _test_SimplePlotter() 388 print ' testing Plotter' 389 _test_Plotter() 390 print 'testing CamPlotter ... testing what happens if doubled IDs in mask' 343 391 _test_CamPlotter() 344 #_test_HistPlotter() 392 print 'testing basic HistPlotter functionality' 393 _test_HistPlotter() 394
Note:
See TracChangeset
for help on using the changeset viewer.