Changeset 620 for trunk/python
- Timestamp:
- 05/05/05 12:20:27 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplot.py
r491 r620 65 65 self.colours = [1, 'b', 'g', 'r', 'c', 'm', 'y', 'k'] 66 66 self.attributes = {} 67 self.loc = 167 self.loc = 0 68 68 69 69 matplotlib.interactive = True … … 80 80 for i in range(1,len(self.lines)+1): 81 81 self.delete(i) 82 83 82 self.axes.clear() 84 83 self.colours[0] = 1 … … 103 102 line.set_linestyle('None') 104 103 self.lines[number] = None 105 106 self.show() 107 104 self.show() 108 105 109 106 def get_line(self): … … 150 147 151 148 152 def legend(self, loc= 1):149 def legend(self, loc=None): 153 150 """ 154 151 Add a legend to the plot. … … 167 164 168 165 """ 169 if 1 > loc > 10: loc = 0 170 self.loc = loc 166 if isinstance(loc,int): 167 if 0 > loc > 10: loc = 0 168 self.loc = loc 171 169 self.show() 172 170 … … 512 510 ylim = [ymin, ymax] as in axes.set_ylim(). 513 511 """ 514 515 512 for s in self.subplots: 516 513 self.axes = s['axes'] 517 514 self.lines = s['lines'] 518 if xlim is not None: 519 self.axes.set_xlim(xlim) 520 if ylim is not None: 521 self.axes.set_ylim(ylim) 522 return 515 oldxlim = list(self.axes.get_xlim()) 516 oldylim = list(self.axes.get_ylim()) 517 if xlim is not None: 518 for i in range(len(xlim)): 519 if xlim[i] is not None: 520 oldxlim[i] = xlim[i] 521 if ylim is not None: 522 for i in range(len(ylim)): 523 if ylim[i] is not None: 524 oldylim[i] = ylim[i] 525 self.axes.set_xlim(oldxlim) 526 self.axes.set_ylim(oldylim) 527 return 523 528 524 529 … … 568 573 569 574 570 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1 ):575 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, ganged=True): 571 576 """ 572 577 Set the panel layout. … … 626 631 cols, i+1) 627 632 self.subplots[i]['lines'] = [] 628 629 if rows > 1 or cols > 1: 630 # Squeeze the plots together. 631 pos = self.subplots[i]['axes'].get_position() 632 if cols > 1: pos[2] *= 1.1 633 if rows > 1: pos[3] *= 1.1 634 self.subplots[i]['axes'].set_position(pos) 635 636 # Suppress tick labelling for interior subplots. 637 if i <= (rows-1)*cols - 1: 638 # Suppress x-labels for frames not in the bottom row. 639 for tick in self.subplots[i]['axes'].xaxis.majorTicks: 640 tick.label1On = False 641 642 if i%cols: 643 # Suppress y-labels for frames not in the left column. 644 for tick in self.subplots[i]['axes'].yaxis.majorTicks: 645 tick.label1On = False 633 xfsize = self.subplots[i]['axes'].xaxis.label.get_size()-cols/2 634 yfsize = self.subplots[i]['axes'].yaxis.label.get_size()-rows/2 635 self.subplots[i]['axes'].xaxis.label.set_size(xfsize) 636 self.subplots[i]['axes'].yaxis.label.set_size(yfsize) 637 638 if ganged: 639 if rows > 1 or cols > 1: 640 # Squeeze the plots together. 641 pos = self.subplots[i]['axes'].get_position() 642 if cols > 1: pos[2] *= 1.2 643 if rows > 1: pos[3] *= 1.2 644 self.subplots[i]['axes'].set_position(pos) 645 646 # Suppress tick labelling for interior subplots. 647 if i <= (rows-1)*cols - 1: 648 if i+cols < nplots: 649 # Suppress x-labels for frames width 650 # adjacent frames 651 for tick in \ 652 self.subplots[i]['axes'].xaxis.majorTicks: 653 tick.label1On = False 654 self.subplots[i]['axes'].xaxis.label.set_visible(False) 655 if i%cols: 656 # Suppress y-labels for frames not in the left column. 657 for tick in self.subplots[i]['axes'].yaxis.majorTicks: 658 tick.label1On = False 659 self.subplots[i]['axes'].yaxis.label.set_visible(False) 660 646 661 647 662 self.rows = rows … … 650 665 self.subplot(0) 651 666 652 653 667 def set_title(self, title=None): 654 668 """ … … 667 681 """ 668 682 if not self.buffering: 669 if self.loc :683 if self.loc is not None: 670 684 for j in range(len(self.subplots)): 671 685 lines = [] … … 691 705 self.canvas.show() 692 706 693 694 707 def subplot(self, i=None, inc=None): 695 708 """
Note:
See TracChangeset
for help on using the changeset viewer.