Changeset 1086 for trunk/python
- Timestamp:
- 07/27/06 14:38:57 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotbase.py
r1032 r1086 137 137 138 138 139 def hist(self, x=None, y=None, msk=None,fmt=None, add=None):139 def hist(self, x=None, y=None, fmt=None, add=None): 140 140 """ 141 141 Plot a histogram. N.B. the x values refer to the start of the … … 144 144 fmt is the line style as in plot(). 145 145 """ 146 146 from matplotlib.numerix import array 147 from matplotlib.numerix.ma import MaskedArray 147 148 if x is None: 148 149 if y is None: return … … 153 154 l2 = 2*len(x) 154 155 x2 = range(l2) 156 y2 = range(12) 155 157 y2 = range(l2) 156 158 m2 = range(l2) 157 159 ymsk = y.raw_mask() 160 ydat = y.raw_data() 158 161 for i in range(l2): 159 162 x2[i] = x[i/2] 160 m2[i] = msk[i/2]163 m2[i] = ymsk[i/2] 161 164 162 165 y2[0] = 0.0 163 166 for i in range(1,l2): 164 y2[i] = y [(i-1)/2]165 166 self.plot(x2, y2, m2, fmt, add)167 y2[i] = ydat[(i-1)/2] 168 169 self.plot(x2, MaskedArray(y2,mask=m2,copy=0), fmt, add) 167 170 168 171 … … 197 200 198 201 199 def plot(self, x=None, y=None, mask=None,fmt=None, add=None):202 def plot(self, x=None, y=None, fmt=None, add=None): 200 203 """ 201 204 Plot the next line in the current frame using the current line … … 211 214 y = x 212 215 x = range(len(y)) 213 214 ax = self.axes 215 s = ax.title.get_size() 216 tsize = s-(self.cols+self.rows)/2 217 ax.title.set_size(tsize) 218 origx = ax.xaxis.label.get_size() #rcParams['xtick.labelsize'] 219 origy = ax.yaxis.label.get_size() #rcParams['ytick.labelsize'] 220 if self.cols > 1: 221 xfsize = origx-(self.cols)/2 222 #rc('xtick',labelsize=xfsize) 223 ax.xaxis.label.set_size(xfsize) 224 if self.rows > 1: 225 yfsize = origy-(self.rows)/2 226 #rc('ytick',labelsize=yfsize) 227 ax.yaxis.label.set_size(yfsize) 228 if mask is None: 229 if fmt is None: 230 line = self.axes.plot(x, y) 231 else: 232 line = self.axes.plot(x, y, fmt) 216 if fmt is None: 217 line = self.axes.plot(x, y) 233 218 else: 234 segments = [] 235 236 mask = list(mask) 237 i = 0 238 while mask[i:].count(1): 239 i += mask[i:].index(1) 240 if mask[i:].count(0): 241 j = i + mask[i:].index(0) 242 else: 243 j = len(mask) 244 245 segments.append(x[i:j]) 246 segments.append(y[i:j]) 247 248 i = j 249 250 line = self.axes.plot(*segments) 251 #rc('xtick',labelsize=origx) 252 #rc('ytick',labelsize=origy) 219 line = self.axes.plot(x, y, fmt) 253 220 254 221 # Add to an existing line? 222 i = None 255 223 if add is None or len(self.lines) < add < 0: 256 224 # Don't add. … … 274 242 if len(self.colormap) == 1: 275 243 getattr(segment, "set_dashes")(self.linestyles[self.linestyle]) 244 276 245 self.color += 1 277 246 if self.color >= len(self.colormap): … … 681 650 if not self.buffering: 682 651 if self.loc is not None: 683 for j in range(len(self.subplots)):652 for sp in self.subplots: 684 653 lines = [] 685 654 labels = [] 686 655 i = 0 687 for line in s elf.subplots[j]['lines']:656 for line in sp['lines']: 688 657 i += 1 689 658 if line is not None: … … 695 664 696 665 if len(lines): 697 self.subplots[j]['axes'].legend(tuple(lines), 698 tuple(labels), 699 self.loc) 666 rcParams['legend.fontsize'] = 8 667 ## lsiz = rcParams['legend.fontsize']-len(lines)/2 668 sp['axes'].legend(tuple(lines), tuple(labels), 669 self.loc) 670 ## ,prop=FontProperties(size=lsiz) ) 700 671 else: 701 self.subplots[j]['axes'].legend((' ')) 702 672 sp['axes'].legend((' ')) 673 674 ax = sp['axes'] 675 from matplotlib.artist import setp 676 xts = rcParams['xtick.labelsize']-(self.cols)/2 677 yts = rcParams['ytick.labelsize']-(self.rows)/2 678 for sp in self.subplots: 679 ax = sp['axes'] 680 s = ax.title.get_size() 681 tsize = s-(self.cols+self.rows) 682 ax.title.set_size(tsize) 683 setp(ax.get_xticklabels(), fontsize=xts) 684 setp(ax.get_yticklabels(), fontsize=yts) 685 origx = rcParams['xtick.labelsize'] #ax.xaxis.label.get_size() 686 origy = rcParams['ytick.labelsize'] #ax.yaxis.label.get_size() 687 off = 0 688 if self.cols > 1: off = self.cols 689 xfsize = origx-off 690 #rc('xtick',labelsize=xfsize) 691 ax.xaxis.label.set_size(xfsize) 692 off = 0 693 if self.rows > 1: off = self.rows 694 yfsize = origy-off 695 #rc('ytick',labelsize=yfsize) 696 ax.yaxis.label.set_size(yfsize) 703 697 704 698 def subplot(self, i=None, inc=None):
Note:
See TracChangeset
for help on using the changeset viewer.