Changeset 1101 for trunk/python
- Timestamp:
- 08/02/06 09:35:30 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapplotter.py
r1096 r1101 38 38 self._selection = selector() 39 39 self._hist = rcParams['plotter.histogram'] 40 from matplotlib import rc as mplrc 41 mplrc('legend',fontsize=8) 40 42 41 43 def _translate(self, instr): … … 72 74 from asap import scantable 73 75 if not self._data and not scan: 74 print "please provide a scantable to plot" 76 msg = "Input is not a scantable" 77 if rcParams['verbose']: 78 print msg 79 return 80 raise TypeError(msg) 75 81 if isinstance(scan, scantable): 76 82 if self._data is not None: … … 181 187 return 182 188 183 def set_legend(self, mp=None, mode = 0):189 def set_legend(self, mp=None, fontsize = None, mode = 0): 184 190 """ 185 191 Specify a mapping for the legend instead of using the default 186 192 indices: 187 193 Parameters: 188 mp: a list of 'strings'. This should have the same length 189 as the number of elements on the legend and then maps 190 to the indeces in order. It is possible to uses latex 191 math expression. These have to be enclosed in r'', e.g. r'$x^{2}$' 192 mode: where to display the legend 193 Any other value for loc else disables the legend: 194 mp: a list of 'strings'. This should have the same length 195 as the number of elements on the legend and then maps 196 to the indeces in order. It is possible to uses latex 197 math expression. These have to be enclosed in r'', 198 e.g. r'$x^{2}$' 199 fontsize: The font size of the label (default None) 200 mode: where to display the legend 201 Any other value for loc else disables the legend: 194 202 0: auto 195 203 1: upper right … … 214 222 self._lmap = mp 215 223 self._plotter.legend(mode) 224 if isinstance(fontsize, int): 225 from matplotlib import rc as rcp 226 rcp('legend', fontsize=fontsize) 216 227 if self._data: 217 228 self.plot(self._data) 218 229 return 219 230 220 def set_title(self, title=None ):231 def set_title(self, title=None, fontsize=None): 221 232 """ 222 233 Set the title of the plot. If multiple panels are plotted, … … 227 238 """ 228 239 self._title = title 229 if self._data: self.plot(self._data) 230 return 231 232 def set_ordinate(self, ordinate=None): 240 if isinstance(fontsize, int): 241 from matplotlib import rc as rcp 242 rcp('axes', titlesize=fontsize) 243 if self._data: self.plot(self._data) 244 return 245 246 def set_ordinate(self, ordinate=None, fontsize=None): 233 247 """ 234 248 Set the y-axis label of the plot. If multiple panels are plotted, … … 242 256 """ 243 257 self._ordinate = ordinate 244 if self._data: self.plot(self._data) 245 return 246 247 def set_abcissa(self, abcissa=None): 258 if isinstance(fontsize, int): 259 from matplotlib import rc as rcp 260 rcp('axes', labelsize=fontsize) 261 rcp('ytick', labelsize=fontsize) 262 if self._data: self.plot(self._data) 263 return 264 265 def set_abcissa(self, abcissa=None, fontsize=None): 248 266 """ 249 267 Set the x-axis label of the plot. If multiple panels are plotted, … … 257 275 """ 258 276 self._abcissa = abcissa 277 if isinstance(fontsize, int): 278 from matplotlib import rc as rcp 279 rcp('axes', labelsize=fontsize) 280 rcp('xtick', labelsize=fontsize) 259 281 if self._data: self.plot(self._data) 260 282 return … … 277 299 if self._data: self.plot(self._data) 278 300 279 def set_histogram(self, hist=True ):301 def set_histogram(self, hist=True, linewidth=None): 280 302 """ 281 303 Enable/Disable histogram-like plotting. … … 286 308 """ 287 309 self._hist = hist 288 if self._data: self.plot(self._data) 289 290 def set_linestyles(self, linestyles): 310 if isinstance(linewidth, float) or isinstance(linewidth, int): 311 from matplotlib import rc as rcp 312 rcp('lines', linewidth=linewidth) 313 if self._data: self.plot(self._data) 314 315 def set_linestyles(self, linestyles=None, linewidth=None): 291 316 """ 292 317 Set the linestyles to be used. The plotter will cycle through … … 309 334 linestyles = linestyles.split() 310 335 self._plotter.palette(color=0,linestyle=0,linestyles=linestyles) 336 if isinstance(linewidth, float) or isinstance(linewidth, int): 337 from matplotlib import rc as rcp 338 rcp('lines', linewidth=linewidth) 339 if self._data: self.plot(self._data) 340 341 def set_font(self, family=None, style=None, weight=None, size=None): 342 """ 343 Set font properties. 344 Parameters: 345 family: one of 'sans-serif', 'serif', 'cursive', 'fantasy', 'monospace' 346 style: one of 'normal' (or 'roman'), 'italic' or 'oblique' 347 weight: one of 'normal or 'bold' 348 size: the 'general' font size, individual elements can be adjusted 349 seperately 350 """ 351 from matplotlib import rc as rcp 352 if isinstance(family, str): 353 rcp('font', family=family) 354 if isinstance(style, str): 355 rcp('font', style=style) 356 if isinstance(weight, str): 357 rcp('font', weight=weight) 358 if isinstance(size, float) or isinstance(size, int): 359 rcp('font', size=size) 311 360 if self._data: self.plot(self._data) 312 361 … … 379 428 inc = -1 380 429 # find min index 381 while data[start] < mn:430 while start > 0 and data[start] < mn: 382 431 start+= inc 383 432 # find max index 384 while data[end] > mx:433 while end > 0 and data[end] > mx: 385 434 end-=inc 386 end +=1435 if end > 0: end +=1 387 436 if start > end: 388 437 return end,start … … 491 540 plotit = self._plotter.plot 492 541 if self._hist: plotit = self._plotter.hist 493 plotit(x,y)542 if len(x) > 0: plotit(x,y) 494 543 xlim= self._minmaxx or [min(x),max(x)] 495 544 allxlim += xlim
Note:
See TracChangeset
for help on using the changeset viewer.