/[ascend]/trunk/pygtk/plot.i
ViewVC logotype

Contents of /trunk/pygtk/plot.i

Parent Directory Parent Directory | Revision Log Revision Log


Revision 182 - (show annotations) (download)
Thu Jan 12 06:05:35 2006 UTC (13 years, 8 months ago) by johnpye
Original Path: trunk/pygtk/interface/plot.i
File size: 1198 byte(s)
Fixed problem with figure closing causing ASCEND to exit
1 /*
2
3 SWIG interface for plotting from ASCEND
4
5 */
6
7
8 class Plot : public Instanc{
9
10 public:
11 const std::string getTitle() const;
12 const std::string getXLabel() const;
13 const std::string getYLabel() const;
14 const bool isXLog() const;
15 const bool isYLog() const;
16 const double getXLow() const;
17 const double getXHigh() const;
18 const double getYLow() const;
19 const double getYHigh() const;
20
21 std::vector<Curve> curves;
22 };
23
24
25 %extend Plot{
26 %pythoncode{
27 def show(self,mainloop=True):
28 import pylab
29 pylab.ion()
30 pylab.figure()
31 pylab.title(self.getTitle())
32 print "XLabel:",self.getXLabel()
33 pylab.xlabel(self.getXLabel())
34 print "YLabel:",self.getYLabel()
35 pylab.ylabel(self.getYLabel())
36 _l = []
37 for _c in self.curves:
38 if self.isXLog() and self.isYLog():
39 pylab.loglog(_c.x, _c.y)
40 elif self.isXLog():
41 pylab.semilogx(_c.x, _c.y)
42 elif self.isYLog():
43 pylab.semilogy(_c.x, _c.y)
44 else:
45 pylab.plot(_c.x, _c.y)
46 _l.append(_c.getLegend())
47 pylab.legend(_l)
48
49 print "Mainloop:",mainloop
50 pylab.show(mainloop)
51
52 # /*
53 # if self.getXLow() and self.getXHigh():
54 # matplotlib.gca().set_xlim([self.getXLow(), self.getXHigh()])
55 # */
56 }
57 }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22