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 |
} |