Changeset 1547
- Timestamp:
- 03/27/09 15:59:45 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r1391 r1547 1 from asap import rcParams, print_log, selector 1 from asap import rcParams, print_log, selector, scantable 2 2 import matplotlib.axes 3 3 import re … … 101 101 return 102 102 103 def create_mask(self, **kwargs): 104 nwindows = 1 105 if kwargs.has_key("nwindows"): 106 nwindows = kwargs.pop("nwindows") 107 outmask = [] 108 for w in xrange(nwindows): 109 wpos = [] 110 wpos.append(self._plotter.get_point()[0]) 111 self.axvline(wpos[0], **kwargs) 112 wpos.append(self._plotter.get_point()[0]) 113 del self._plotter.axes.lines[-1] 114 kwargs["alpha"] = 0.1 115 self.axvspan(wpos[0], wpos[1], **kwargs) 116 outmask.append(wpos) 117 return self._data.create_mask(*outmask) 103 118 104 119 # forwards to matplotlib axes 105 120 def text(self, *args, **kwargs): 121 if kwargs.has_key("interactive"): 122 if kwargs.pop("interactive"): 123 pos = self._plotter.get_point() 124 args = tuple(pos)+args 106 125 self._axes_callback("text", *args, **kwargs) 126 107 127 text.__doc__ = matplotlib.axes.Axes.text.__doc__ 108 128 def arrow(self, *args, **kwargs): 129 if kwargs.has_key("interactive"): 130 if kwargs.pop("interactive"): 131 pos = self._plotter.get_region() 132 dpos = (pos[0][0], pos[0][1], 133 pos[1][0]-pos[0][0], 134 pos[1][1] - pos[0][1]) 135 args = dpos + args 109 136 self._axes_callback("arrow", *args, **kwargs) 137 110 138 arrow.__doc__ = matplotlib.axes.Axes.arrow.__doc__ 111 139 def axvline(self, *args, **kwargs): 140 if kwargs.has_key("interactive"): 141 if kwargs.pop("interactive"): 142 pos = self._plotter.get_point() 143 args = (pos[0],)+args 112 144 self._axes_callback("axvline", *args, **kwargs) 113 145 axvline.__doc__ = matplotlib.axes.Axes.axvline.__doc__ 146 114 147 def axhline(self, *args, **kwargs): 148 if kwargs.has_key("interactive"): 149 if kwargs.pop("interactive"): 150 pos = self._plotter.get_point() 151 args = (pos[1],)+args 115 152 self._axes_callback("axhline", *args, **kwargs) 116 153 axhline.__doc__ = matplotlib.axes.Axes.axhline.__doc__ 154 117 155 def axvspan(self, *args, **kwargs): 156 if kwargs.has_key("interactive"): 157 if kwargs.pop("interactive"): 158 pos = self._plotter.get_region() 159 dpos = (pos[0][0], pos[1][0]) 160 args = dpos + args 118 161 self._axes_callback("axvspan", *args, **kwargs) 119 162 # hack to preventy mpl from redrawing the patch 120 163 # it seem to convert the patch into lines on every draw. 121 164 # This doesn't happen in a test script??? 122 del self._plotter.axes.patches[-1] 165 #del self._plotter.axes.patches[-1] 166 123 167 axvspan.__doc__ = matplotlib.axes.Axes.axvspan.__doc__ 124 168 125 169 def axhspan(self, *args, **kwargs): 170 if kwargs.has_key("interactive"): 171 if kwargs.pop("interactive"): 172 pos = self._plotter.get_region() 173 dpos = (pos[0][1], pos[1][1]) 174 args = dpos + args 175 126 176 self._axes_callback("axhspan", *args, **kwargs) 127 177 # hack to preventy mpl from redrawing the patch 128 178 # it seem to convert the patch into lines on every draw. 129 179 # This doesn't happen in a test script??? 130 del self._plotter.axes.patches[-1]180 #del self._plotter.axes.patches[-1] 131 181 axhspan.__doc__ = matplotlib.axes.Axes.axhspan.__doc__ 132 182 … … 148 198 self._plotter.axes.set_autoscale_on(True) 149 199 # end matplotlib.axes fowarding functions 200 150 201 151 202 def set_mode(self, stacking=None, panelling=None): … … 390 441 if self._data: self.plot(self._data) 391 442 392 def set_font(self, family=None, style=None, weight=None, size=None):443 def set_font(self, **kwargs): 393 444 """ 394 445 Set font properties. … … 401 452 """ 402 453 from matplotlib import rc as rcp 403 if isinstance(family, str): 404 rcp('font', family=family) 405 if isinstance(style, str): 406 rcp('font', style=style) 407 if isinstance(weight, str): 408 rcp('font', weight=weight) 409 if isinstance(size, float) or isinstance(size, int): 410 rcp('font', size=size) 411 if self._data: self.plot(self._data) 454 fdict = {} 455 for k,v in kwargs.iteritems(): 456 if v: 457 fdict[k] = v 458 rcp('font', **fdict) 459 if self._data: 460 self.plot(self._data) 412 461 413 462 def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate=90.0, … … 632 681 ylab = self._ordinate and self._ordinate[panelcount] \ 633 682 or scan._get_ordinate_label() 634 self._plotter.set_axes('xlabel', xlab)635 self._plotter.set_axes('ylabel', ylab)683 self._plotter.set_axes('xlabel', xlab) 684 self._plotter.set_axes('ylabel', ylab) 636 685 lbl = self._get_label(scan, r, self._panelling, self._title) 637 686 if isinstance(lbl, list) or isinstance(lbl, tuple):
Note:
See TracChangeset
for help on using the changeset viewer.