Changeset 702 for trunk/python
- Timestamp:
- 10/20/05 16:56:42 (19 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplot.py
r665 r702 17 17 from matplotlib.numerix import sqrt 18 18 from matplotlib import rc, rcParams 19 from asap import rcParams as asaprcParams 19 20 20 21 # Force use of the newfangled toolbar. … … 58 59 self.set_panels(rows, cols) 59 60 60 61 # Set matplotlib default colour sequence. 62 self.colormap = ['blue', 'green', 'red', 'cyan', 'magenta', 'yellow', 'black', 'purple', 'orange', 'pink'] 61 # Set matplotlib default colour sequence. 62 self.colormap = "green red black cyan magenta orange blue purple yellow pink".split() 63 64 c = asaprcParams['plotter.colours'] 65 if isinstance(c,str) and len(c) > 0: 66 self.colormap = c.split() 67 68 self.lsalias = {"line": [1,0], 69 "dashdot": [4,2,1,2], 70 "dashed" : [4,2,4,2], 71 "dotted" : [1,2], 72 "dashdotdot": [4,2,1,2,1,2], 73 "dashdashdot": [4,2,4,2,1,2] 74 } 75 76 styles = "line dashed dotted dashdot".split() 77 c = asaprcParams['plotter.linestyles'] 78 if isinstance(c,str) and len(c) > 0: 79 styles = c.split() 80 s = [] 81 for ls in styles: 82 if self.lsalias.has_key(ls): 83 s.append(self.lsalias.get(ls)) 84 else: 85 s.append('-') 86 self.linestyles = s 87 63 88 self.color = 0; 89 self.linestyle = 0; 64 90 self.attributes = {} 65 91 self.loc = 0 … … 80 106 self.axes.clear() 81 107 self.color = 0 108 self.linestyle = 0 82 109 self.lines = [] 83 110 84 85 def palette(self, color, colormap=None): 111 def palette(self, color, colormap=None, linestyle=0, linestyles=None): 86 112 if colormap: 87 self.colormap = colormap 113 if isinstance(colormap,list): 114 self.colormap = colormap 115 elif isinstance(colormap,str): 116 self.colormap = colormap.split() 88 117 if 0 <= color < len(self.colormap): 89 118 self.color = color 119 if linestyles: 120 self.linestyles = [] 121 if isinstance(linestyles,list): 122 styles = linestyles 123 elif isinstance(linestyles,str): 124 styles = linestyles.split() 125 for ls in styles: 126 if self.lsalias.has_key(ls): 127 self.linestyles.append(self.lsalias.get(ls)) 128 else: 129 self.linestyles.append(self.lsalias.get('line')) 130 if 0 <= linestyle < len(self.linestyles): 131 self.linestyle = linestyle 90 132 91 133 def delete(self, numbers=None): … … 244 286 for segment in self.lines[i]: 245 287 getattr(segment, "set_color")(self.colormap[self.color]) 246 288 if len(self.colormap) == 1: 289 getattr(segment, "set_dashes")(self.linestyles[self.linestyle]) 247 290 self.color += 1 248 291 if self.color >= len(self.colormap): 249 292 self.color = 0 293 294 if len(self.colormap) == 1: 295 self.linestyle += 1 296 if self.linestyle >= len(self.linestyles): 297 self.linestyle = 0 250 298 251 299 self.show() … … 380 428 381 429 382 def save(self, fname=None, orientation= 'landscape'):430 def save(self, fname=None, orientation=None): 383 431 """ 384 432 Save the plot to a file. … … 401 449 if fname[-3:].lower() in d: 402 450 try: 403 self.canvas.print_figure(fname,orientation=orientation) 404 print 'Written file %s' % (fname) 451 if fname[-3:].lower() == ".ps": 452 w = self.figure.figwidth.get() 453 h = self.figure.figheight.get() 454 a4w = 8.25 455 a4h = 11.25 456 457 if orientation is None: 458 # auto oriented 459 if w > h: 460 orientation = 'landscape' 461 else: 462 orientation = 'portrait' 463 ds = None 464 if orientation == 'landscape': 465 ds = min(a4h/w,a4w/h) 466 #self.figure.set_figsize_inches((a4h,a4w)) 467 else: 468 ds = min(a4w/w,a4h/h) 469 ow = ds * w 470 oh = ds * h 471 self.figure.set_figsize_inches((ow,oh)) 472 self.canvas.print_figure(fname,orientation=orientation) 473 print 'Written file %s' % (fname) 474 else: 475 self.canvas.print_figure(fname) 476 print 'Written file %s' % (fname) 405 477 except IOError, msg: 406 478 print 'Failed to save %s: Error msg was\n\n%s' % (fname, err) … … 408 480 else: 409 481 print "Invalid image type. Valid types are:" 410 print " ps, eps, png"482 print "'ps', 'eps', 'png'" 411 483 412 484 -
trunk/python/asapplotter.py
r700 r702 212 212 else: 213 213 self._plotter.set_panels() 214 215 214 for scan in scans: 216 215 self._plotter.palette(0)
Note:
See TracChangeset
for help on using the changeset viewer.