- Timestamp:
- 08/16/06 11:36:23 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotbase.py
r1100 r1147 9 9 10 10 from matplotlib.figure import Figure, Text 11 from matplotlib.font_manager import FontProperties 11 from matplotlib.font_manager import FontProperties as FP 12 12 from matplotlib.numerix import sqrt 13 13 from matplotlib import rc, rcParams … … 15 15 from matplotlib.ticker import ScalarFormatter 16 16 from matplotlib.ticker import NullLocator 17 from matplotlib.transforms import blend_xy_sep_transform 18 17 19 if int(matplotlib.__version__.split(".")[1]) < 87: 18 20 print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." … … 82 84 def clear(self): 83 85 """ 84 Delete all lines from the plot. Line numbering will restart from 1.86 Delete all lines from the plot. Line numbering will restart from 0. 85 87 """ 86 88 … … 410 412 411 413 if orientation is None: 412 # autooriented414 # oriented 413 415 if w > h: 414 416 orientation = 'landscape' … … 666 668 667 669 if len(lines): 670 fp = FP(size=rcParams['legend.fontsize']) 671 fsz = fp.get_size_in_points() - len(lines) 672 fp.set_size(max(fsz,6)) 668 673 sp['axes'].legend(tuple(lines), tuple(labels), 669 self.loc) 670 ## ,prop=FontProperties(size=lsiz) ) 674 self.loc, prop=fp) 671 675 else: 672 676 sp['axes'].legend((' ')) 673 677 674 678 from matplotlib.artist import setp 675 xts = rcParams['xtick.labelsize']-(self.cols)/2 676 yts = rcParams['ytick.labelsize']-(self.rows)/2 679 fp = FP(size=rcParams['xtick.labelsize']) 680 xts = fp.get_size_in_points()- (self.cols)/2 681 fp = FP(size=rcParams['ytick.labelsize']) 682 yts = fp.get_size_in_points() - (self.rows)/2 677 683 for sp in self.subplots: 678 684 ax = sp['axes'] … … 680 686 tsize = s-(self.cols+self.rows) 681 687 ax.title.set_size(tsize) 688 fp = FP(size=rcParams['axes.labelsize']) 682 689 setp(ax.get_xticklabels(), fontsize=xts) 683 690 setp(ax.get_yticklabels(), fontsize=yts) 684 origx = rcParams['axes.labelsize'] #ax.xaxis.label.get_size()685 origy = rcParams['axes.labelsize'] #ax.yaxis.label.get_size()691 origx = fp.get_size_in_points() 692 origy = origx 686 693 off = 0 687 694 if self.cols > 1: off = self.cols 688 695 xfsize = origx-off 689 #rc('xtick',labelsize=xfsize)690 696 ax.xaxis.label.set_size(xfsize) 691 697 off = 0 692 698 if self.rows > 1: off = self.rows 693 699 yfsize = origy-off 694 #rc('ytick',labelsize=yfsize)695 700 ax.yaxis.label.set_size(yfsize) 696 701 … … 712 717 self.lines = self.subplots[self.i]['lines'] 713 718 714 715 719 def text(self, *args, **kwargs): 716 720 """ … … 719 723 self.figure.text(*args, **kwargs) 720 724 self.show() 725 726 def vline_with_label(self, x, y, label, 727 location='bottom', rotate=0.0, **kwargs): 728 """ 729 Plot a vertical line with label. 730 It takes "world" values fo x and y. 731 """ 732 ax = self.axes 733 # need this to suppress autoscaling during this function 734 self.axes.set_autoscale_on(False) 735 ymin = 0.0 736 ymax = 1.0 737 valign = 'center' 738 if location.lower() == 'top': 739 y = max(0.0, y) 740 elif location.lower() == 'bottom': 741 y = min(0.0, y) 742 lbloffset = 0.06 743 # a rough estimate for the bb of the text 744 if rotate > 0.0: lbloffset = 0.03*len(label) 745 peakoffset = 0.01 746 xy0 = ax.transData.xy_tup((x,y)) 747 # get relative coords 748 xy = ax.transAxes.inverse_xy_tup(xy0) 749 if location.lower() == 'top': 750 ymax = 1.0-lbloffset 751 ymin = xy[1]+peakoffset 752 valign = 'bottom' 753 ylbl = ymax+0.01 754 elif location.lower() == 'bottom': 755 ymin = lbloffset 756 ymax = xy[1]-peakoffset 757 valign = 'top' 758 ylbl = ymin-0.01 759 trans = blend_xy_sep_transform(ax.transData, ax.transAxes) 760 l = ax.axvline(x, ymin, ymax, color='black', **kwargs) 761 t = ax.text(x, ylbl ,label, verticalalignment=valign, 762 horizontalalignment='center', 763 rotation=rotate,transform = trans) 764 self.axes.set_autoscale_on(True)
Note:
See TracChangeset
for help on using the changeset viewer.