Changeset 1779 for branches/mergetest/python/asaplotbase.py
- Timestamp:
- 07/29/10 19:13:46 (14 years ago)
- Location:
- branches/mergetest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mergetest
- Property svn:mergeinfo changed
-
branches/mergetest/python/asaplotbase.py
r1739 r1779 21 21 from matplotlib.transforms import blend_xy_sep_transform as blended_transform_factory 22 22 23 from asap import asaplog 24 23 25 if int(matplotlib.__version__.split(".")[1]) < 87: 24 print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 26 #print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 27 asaplog.push( "matplotlib version < 0.87. This might cause errors. Please upgrade." ) 28 print_log( 'WARN' ) 25 29 26 30 class asaplotbase: … … 147 151 from numpy import array 148 152 from numpy.ma import MaskedArray 149 150 153 if x is None: 151 154 if y is None: return … … 168 171 ymsk = y.mask 169 172 ydat = y.data 170 171 173 for i in range(l2): 172 174 x2[i] = x[i/2] … … 280 282 281 283 282 def get_region(self):283 pos = []284 print "Please select the bottom/left point"285 pos.append(self.figure.ginput(n=1, show_clicks=False)[0])286 print "Please select the top/right point"287 pos.append(self.figure.ginput(n=1, show_clicks=False)[0])288 return pos289 290 def get_point(self):291 print "Please select the point"292 pt = self.figure.ginput(n=1, show_clicks=False)293 if pt:294 return pt[0]295 else:296 return None284 # def get_region(self): 285 # pos = [] 286 # print "Please select the bottom/left point" 287 # pos.append(self.figure.ginput(n=1, show_clicks=False)[0]) 288 # print "Please select the top/right point" 289 # pos.append(self.figure.ginput(n=1, show_clicks=False)[0]) 290 # return pos 291 292 # def get_point(self): 293 # print "Please select the point" 294 # pt = self.figure.ginput(n=1, show_clicks=False) 295 # if pt: 296 # return pt[0] 297 # else: 298 # return None 297 299 298 300 def region(self): … … 304 306 305 307 def region_start(event): 306 height = self.canvas.figure.bbox.height() 307 self.rect = {'fig': None, 'height': height, 308 'x': event.x, 'y': height - event.y, 308 self.rect = {'x': event.x, 'y': event.y, 309 309 'world': [event.xdata, event.ydata, 310 310 event.xdata, event.ydata]} … … 314 314 315 315 def region_draw(event): 316 self.canvas._tkcanvas.delete(self.rect['fig']) 317 self.rect['fig'] = self.canvas._tkcanvas.create_rectangle( 318 self.rect['x'], self.rect['y'], 319 event.x, self.rect['height'] - event.y) 320 316 self.figmgr.toolbar.draw_rubberband(event, event.x, event.y, 317 self.rect['x'], self.rect['y']) 318 321 319 def region_disable(event): 322 320 self.register('motion_notify', None) 323 321 self.register('button_release', None) 324 325 self.canvas._tkcanvas.delete(self.rect['fig'])326 322 327 323 self.rect['world'][2:4] = [event.xdata, event.ydata] … … 329 325 self.rect['world'][1], self.rect['world'][2], 330 326 self.rect['world'][3]) 327 self.figmgr.toolbar.release(event) 331 328 332 329 self.register('button_press', region_start) … … 381 378 self.events[type] = None 382 379 383 # It seems to be necessary to return events to the toolbar. 384 if type == 'motion_notify':385 self.canvas.mpl_connect(type + '_event',386 self.figmgr.toolbar.mouse_move)387 elif type == 'button_press':388 self.canvas.mpl_connect(type + '_event',389 self.figmgr.toolbar.press)390 elif type == 'button_release':391 self.canvas.mpl_connect(type + '_event',392 self.figmgr.toolbar.release)380 # It seems to be necessary to return events to the toolbar. <-- Not ture. 2010.Jul.14.kana. 381 #if type == 'motion_notify': 382 # self.canvas.mpl_connect(type + '_event', 383 # self.figmgr.toolbar.mouse_move) 384 #elif type == 'button_press': 385 # self.canvas.mpl_connect(type + '_event', 386 # self.figmgr.toolbar.press) 387 #elif type == 'button_release': 388 # self.canvas.mpl_connect(type + '_event', 389 # self.figmgr.toolbar.release) 393 390 394 391 else: … … 459 456 print 'Written file %s' % (fname) 460 457 except IOError, msg: 461 print 'Failed to save %s: Error msg was\n\n%s' % (fname, msg) 458 #print 'Failed to save %s: Error msg was\n\n%s' % (fname, err) 459 print_log() 460 asaplog.push('Failed to save %s: Error msg was\n\n%s' % (fname, str(msg))) 461 print_log( 'ERROR' ) 462 462 return 463 463 else: 464 print "Invalid image type. Valid types are:" 465 print "'ps', 'eps', 'png'" 464 #print "Invalid image type. Valid types are:" 465 #print "'ps', 'eps', 'png'" 466 asaplog.push( "Invalid image type. Valid types are:" ) 467 asaplog.push( "'ps', 'eps', 'png'" ) 468 print_log('WARN') 466 469 467 470 … … 575 578 576 579 577 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, ganged=True): 580 #def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, ganged=True): 581 def set_panels(self, rows=1, cols=0, n=-1, nplots=-1, layout=None,ganged=True): 578 582 """ 579 583 Set the panel layout. … … 598 602 self.set_title() 599 603 604 if layout: 605 lef, bot, rig, top, wsp, hsp = layout 606 self.figure.subplots_adjust( 607 left=lef,bottom=bot,right=rig,top=top,wspace=wsp,hspace=hsp) 608 del lef,bot,rig,top,wsp,hsp 609 600 610 if rows < 1: rows = 1 601 611 … … 610 620 if 0 <= n < rows*cols: 611 621 i = len(self.subplots) 622 612 623 self.subplots.append({}) 613 624 … … 644 655 cols, i+1) 645 656 if asaprcParams['plotter.axesformatting'] != 'mpl': 646 657 647 658 self.subplots[i]['axes'].xaxis.set_major_formatter(OldScalarFormatter()) 648 659 else: … … 671 682 self.cols = cols 672 683 self.subplot(0) 684 del rows,cols,n,nplots,layout,ganged,i 673 685 674 686 def tidy(self): … … 725 737 sp['axes'].legend((' ')) 726 738 727 728 739 from matplotlib.artist import setp 729 740 fpx = FP(size=rcParams['xtick.labelsize']) … … 734 745 fpat = FP(size=rcParams['axes.titlesize']) 735 746 axsize = fpa.get_size_in_points() 736 tsize = fpat.get_size_in_points() 747 tsize = fpat.get_size_in_points()-(self.cols)/2 737 748 for sp in self.subplots: 738 749 ax = sp['axes'] 739 off = 0 740 if len(self.subplots) > 1: 741 off = self.cols+self.rows 742 ax.title.set_size(tsize-off) 750 ax.title.set_size(tsize) 743 751 setp(ax.get_xticklabels(), fontsize=xts) 744 752 setp(ax.get_yticklabels(), fontsize=yts) 745 753 off = 0 746 if self.cols > 1: 747 off = self.cols 754 if self.cols > 1: off = self.cols 748 755 ax.xaxis.label.set_size(axsize-off) 749 if self.rows > 1:750 756 off = 0 757 if self.rows > 1: off = self.rows 751 758 ax.yaxis.label.set_size(axsize-off) 752 759
Note:
See TracChangeset
for help on using the changeset viewer.