Changeset 1095 for trunk/python
- Timestamp:
- 07/31/06 12:18:37 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplotbase.py
r1086 r1095 15 15 from matplotlib.ticker import ScalarFormatter 16 16 from matplotlib.ticker import NullLocator 17 if int(matplotlib.__version__.split(".")[1]) < 87: 18 print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 17 19 18 20 class MyFormatter(ScalarFormatter): … … 194 196 195 197 """ 196 if isinstance(loc, int):197 if 0 > loc > 10: loc = 0198 if isinstance(loc, int): 199 if 0 >= loc > 10: loc = None 198 200 self.loc = loc 199 self.show() 201 else: 202 self.loc = None 203 #self.show() 200 204 201 205 … … 376 380 377 381 378 def save(self, fname=None, orientation=None, dpi=None ):382 def save(self, fname=None, orientation=None, dpi=None, papertype=None): 379 383 """ 380 384 Save the plot to a file. … … 385 389 directory. 386 390 """ 391 from asap import rcParams 392 if papertype is None: 393 papertype = rcParams['plotter.papertype'] 387 394 if fname is None: 388 395 from datetime import datetime … … 408 415 else: 409 416 orientation = 'portrait' 410 a4w = 8.25411 a4h = 11.25417 from matplotlib.backends.backend_ps import papersize 418 pw,ph = papersize[papertype.lower()] 412 419 ds = None 413 420 if orientation == 'landscape': 414 ds = min( a4h/w,a4w/h)421 ds = min(ph/w, pw/h) 415 422 else: 416 ds = min( a4w/w,a4h/h)423 ds = min(pw/w, ph/h) 417 424 ow = ds * w 418 425 oh = ds * h 419 self.figure.set_figsize_inches((ow,oh)) 420 from matplotlib import __version__ as mv 421 # hack to circument ps bug in eraly versions of mpl 422 if int(mv.split(".")[1]) < 87: 423 self.figure.savefig(fname, orientation=orientation) 424 else: 425 self.figure.savefig(fname, orientation=orientation, 426 papertype="a4") 427 self.figure.set_figsize_inches((w,h)) 426 self.figure.set_figsize_inches((ow, oh)) 427 self.figure.savefig(fname, orientation=orientation, 428 papertype=papertype.lower()) 429 self.figure.set_figsize_inches((w, h)) 428 430 print 'Written file %s' % (fname) 429 431 else: … … 667 669 ## lsiz = rcParams['legend.fontsize']-len(lines)/2 668 670 sp['axes'].legend(tuple(lines), tuple(labels), 669 self.loc) 671 self.loc) 670 672 ## ,prop=FontProperties(size=lsiz) ) 671 673 else: 672 674 sp['axes'].legend((' ')) 673 675 674 ax = sp['axes']675 676 from matplotlib.artist import setp 676 677 xts = rcParams['xtick.labelsize']-(self.cols)/2
Note:
See TracChangeset
for help on using the changeset viewer.