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

Contents of /trunk/ascxx/plot.i

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2327 - (show annotations) (download)
Wed Dec 22 07:17:24 2010 UTC (13 years, 8 months ago) by jpye
File size: 1250 byte(s)
Merging in refactor of the C++ code, which is moved out of 'pygtk' and into 'ascxx'.
Adding support for IPOPT 3.9.1, the current latest version.
Support in dtar for parallel builds (possibly needs some testing still).
1 /*
2
3 SWIG interface for plotting from ASCEND
4
5 */
6
7 %include "plot.h"
8
9 %extend Plot{
10 %pythoncode{
11 def show(self,mainloop=True):
12 import loading
13 loading.load_matplotlib(throw=True)
14 import pylab
15 import platform
16 pylab.ioff()
17 pylab.figure()
18 pylab.title(self.getTitle())
19 print "XLabel:",self.getXLabel()
20 pylab.xlabel(self.getXLabel())
21 print "YLabel:",self.getYLabel()
22 pylab.ylabel(self.getYLabel())
23 _l = []
24 _have_legends = False
25 for _c in self.curves:
26 _f = _c.getFormat()
27 _args = [_c.x, _c.y]
28 if len(_f):
29 _args += [_f]
30 if self.isXLog() and self.isYLog():
31 pylab.loglog(*_args)
32 elif self.isXLog():
33 pylab.semilogx(*_args)
34 elif self.isYLog():
35 pylab.semilogy(*_args)
36 else:
37 pylab.plot(*_args)
38 _l1 = _c.getLegend()
39 if _l1:
40 _have_legends = True
41 _l.append(_l1)
42 # only show legends if their text is non-empty:
43 if _have_legends:
44 pylab.legend(_l,self.getLegendPosition())
45
46 print "Mainloop:",mainloop
47 pylab.ion()
48 if platform.system()=="Windows":
49 pylab.show()
50 else:
51 pylab.show(mainloop)
52
53
54 # /*
55 # if self.getXLow() and self.getXHigh():
56 # matplotlib.gca().set_xlim([self.getXLow(), self.getXHigh()])
57 # */
58 }
59 }

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