Changeset 2037 for trunk/python
- Timestamp:
- 03/13/11 14:38:13 (14 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotbase.py
r1980 r2037 581 581 582 582 #def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, ganged=True): 583 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, layout=None,ganged=True):583 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, margin=None,ganged=True): 584 584 """ 585 585 Set the panel layout. … … 604 604 self.set_title() 605 605 606 if layout:607 lef, bot, rig, top, wsp, hsp = layout606 if margin: 607 lef, bot, rig, top, wsp, hsp = margin 608 608 self.figure.subplots_adjust( 609 609 left=lef,bottom=bot,right=rig,top=top,wspace=wsp,hspace=hsp) … … 689 689 self.cols = cols 690 690 self.subplot(0) 691 del rows,cols,n,nplots, layout,ganged,i691 del rows,cols,n,nplots,margin,ganged,i 692 692 693 693 -
trunk/python/asapplotter.py
r2011 r2037 50 50 self._hist = rcParams['plotter.histogram'] 51 51 self._fp = FontProperties() 52 self._ panellayout = self.set_panellayout(refresh=False)52 self._margins = self.set_margin(refresh=False) 53 53 self._offset = None 54 54 self._startrow = 0 … … 641 641 if refresh and self._data: self.plot(self._data) 642 642 643 def set_ panellayout(self,layout=[],refresh=True):644 """ 645 Set the layout of subplots.646 Parameters: 647 layout: a list of subplots layoutin figure coordinate (0-1),643 def set_margin(self,margin=[],refresh=True): 644 """ 645 Set margins between subplots and plot edges. 646 Parameters: 647 margin: a list of margins in figure coordinate (0-1), 648 648 i.e., fraction of the figure width or height. 649 649 The order of elements should be: … … 654 654 Otherwise,the parameter(s) are set without replotting. 655 655 Note 656 * When layoutis not specified, the values are reset to the defaults656 * When margin is not specified, the values are reset to the defaults 657 657 of matplotlib. 658 658 * If any element is set to be None, the current value is adopted. 659 659 """ 660 if layout == []: self._panellayout=self._reset_panellayout()660 if margin == []: self._margins=self._reset_margin() 661 661 else: 662 self._ panellayout=[None]*6663 self._ panellayout[0:len(layout)]=layout664 #print "panel layout set to ",self._panellayout662 self._margins=[None]*6 663 self._margins[0:len(margin)]=margin 664 #print "panel margin set to ",self._margins 665 665 if refresh and self._data: self.plot(self._data) 666 666 667 def _reset_ panellayout(self):667 def _reset_margin(self): 668 668 ks=map(lambda x: 'figure.subplot.'+x, 669 669 ['left','bottom','right','top','hspace','wspace']) … … 887 887 n = min(n,self._rows*self._cols) 888 888 self._plotter.set_panels(rows=self._rows,cols=self._cols, 889 nplots=n, layout=self._panellayout,ganged=ganged)889 nplots=n,margin=self._margins,ganged=ganged) 890 890 else: 891 self._plotter.set_panels(rows=n,cols=0,nplots=n, layout=self._panellayout,ganged=ganged)891 self._plotter.set_panels(rows=n,cols=0,nplots=n,margin=self._margins,ganged=ganged) 892 892 else: 893 self._plotter.set_panels( layout=self._panellayout)893 self._plotter.set_panels(margin=self._margins) 894 894 #r = 0 895 895 r = self._startrow … … 1150 1150 PL.ioff() 1151 1151 PL.clf() 1152 # Adjust subplot layouts1153 if len(self._ panellayout) != 6:1154 self.set_ panellayout(refresh=False)1155 lef, bot, rig, top, wsp, hsp = self._ panellayout1152 # Adjust subplot margins 1153 if len(self._margins) != 6: 1154 self.set_margin(refresh=False) 1155 lef, bot, rig, top, wsp, hsp = self._margins 1156 1156 PL.gcf().subplots_adjust(left=lef,bottom=bot,right=rig,top=top, 1157 1157 wspace=wsp,hspace=hsp) … … 1250 1250 #PL.ioff() 1251 1251 PL.clf() 1252 # Adjust subplot layouts1253 if len(self._ panellayout) != 6:1254 self.set_ panellayout(refresh=False)1255 lef, bot, rig, top, wsp, hsp = self._ panellayout1252 # Adjust subplot margins 1253 if len(self._margins) != 6: 1254 self.set_margin(refresh=False) 1255 lef, bot, rig, top, wsp, hsp = self._margins 1256 1256 PL.gcf().subplots_adjust(left=lef,bottom=bot,right=rig,top=top, 1257 1257 wspace=wsp,hspace=hsp) … … 1302 1302 # self._datamask = None 1303 1303 1304 # Adjust subplot layouts1305 if len(self._ panellayout) !=6: self.set_panellayout(refresh=False)1306 lef, bot, rig, top, wsp, hsp = self._ panellayout1304 # Adjust subplot margins 1305 if len(self._margins) !=6: self.set_margin(refresh=False) 1306 lef, bot, rig, top, wsp, hsp = self._margins 1307 1307 self._plotter.figure.subplots_adjust( 1308 1308 left=lef,bottom=bot,right=rig,top=top,wspace=wsp,hspace=hsp)
Note:
See TracChangeset
for help on using the changeset viewer.