Changeset 1603 for branches/alma/python/asaplotbase.py
- Timestamp:
- 07/18/09 06:35:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asaplotbase.py
r1446 r1603 15 15 from matplotlib.ticker import OldScalarFormatter 16 16 from matplotlib.ticker import NullLocator 17 from matplotlib.transforms import blend_xy_sep_transform 17 18 # API change in mpl >= 0.98 19 try: 20 from matplotlib.transforms import blended_transform_factory 21 except ImportError: 22 from matplotlib.transforms import blend_xy_sep_transform as blended_transform_factory 18 23 19 24 if int(matplotlib.__version__.split(".")[1]) < 87: … … 161 166 y2 = range(l2) 162 167 m2 = range(l2) 163 #ymsk = y.raw_mask() 164 #ydat = y.raw_data() 165 ymsk = y.mask 166 ydat = y.data 168 ymsk = None 169 ydat = None 170 if hasattr(y, "raw_mask"): 171 # numpy < 1.1 172 ymsk = y.raw_mask() 173 ydat = y.raw_data() 174 else: 175 ymsk = y.mask 176 ydat = y.data 167 177 for i in range(l2): 168 178 x2[i] = x[i/2] … … 410 420 if fname[-3:].lower() == ".ps": 411 421 from matplotlib import __version__ as mv 412 w = self.figure. figwidth.get()413 h = self.figure. figheight.get()422 w = self.figure.get_figwidth() 423 h = self.figure.get_figheight() 414 424 415 425 if orientation is None: … … 428 438 ow = ds * w 429 439 oh = ds * h 430 self.figure.set_ figsize_inches((ow, oh))440 self.figure.set_size_inches((ow, oh)) 431 441 self.figure.savefig(fname, orientation=orientation, 432 442 papertype=papertype.lower()) 433 self.figure.set_ figsize_inches((w, h))443 self.figure.set_size_inches((w, h)) 434 444 print 'Written file %s' % (fname) 435 445 else: … … 617 627 self.subplots[i]['axes'] = self.figure.add_subplot(rows, 618 628 cols, i+1) 619 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 629 if asaprcParams['plotter.xaxisformatting'] == 'mpl': 630 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 620 631 else: 621 632 if i == 0: 622 633 self.subplots[i]['axes'] = self.figure.add_subplot(rows, 623 634 cols, i+1) 624 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 635 if asaprcParams['plotter.xaxisformatting'] != 'mpl': 636 637 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 625 638 else: 626 639 self.subplots[i]['axes'] = self.figure.add_subplot(rows, … … 709 722 for sp in self.subplots: 710 723 ax = sp['axes'] 711 s = rcParams['axes.titlesize']712 tsize = s-(self.cols+self.rows -1)713 ax.title.set_size( max(tsize,9))724 s = ax.title.get_size() 725 tsize = s-(self.cols+self.rows) 726 ax.title.set_size(tsize) 714 727 fp = FP(size=rcParams['axes.labelsize']) 715 728 setp(ax.get_xticklabels(), fontsize=xts) … … 770 783 if rotate > 0.0: lbloffset = 0.03*len(label) 771 784 peakoffset = 0.01 772 xy0 = ax.transData.xy_tup((x,y)) 773 # get relative coords 774 xy = ax.transAxes.inverse_xy_tup(xy0) 785 xy = None 786 xy0 = None 787 # matplotlib api change 0.98 is using transform now 788 if hasattr(ax.transData, "inverse_xy_tup"): 789 # get relative coords 790 xy0 = ax.transData.xy_tup((x,y)) 791 xy = ax.transAxes.inverse_xy_tup(xy0) 792 else: 793 xy0 = ax.transData.transform((x,y)) 794 # get relative coords 795 xy = ax.transAxes.inverted().transform(xy0) 775 796 if location.lower() == 'top': 776 797 ymax = 1.0-lbloffset … … 783 804 valign = 'top' 784 805 ylbl = ymin-0.01 785 trans = blend _xy_sep_transform(ax.transData, ax.transAxes)806 trans = blended_transform_factory(ax.transData, ax.transAxes) 786 807 l = ax.axvline(x, ymin, ymax, color='black', **kwargs) 787 808 t = ax.text(x, ylbl ,label, verticalalignment=valign,
Note: See TracChangeset
for help on using the changeset viewer.