Changeset 693 for branches/Release-2-fixes
- Timestamp:
- 09/29/05 16:35:59 (19 years ago)
- Location:
- branches/Release-2-fixes/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release-2-fixes/python/asaplot.py
r671 r693 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() -
branches/Release-2-fixes/python/asapplotter.py
r672 r693 193 193 194 194 xlim=[min(x),max(x)] 195 if self._minmaxx is not None: 196 xlim = self._minmaxx 195 197 self._plotter.axes.set_xlim(xlim) 196 198 self._plotter.set_axes('xlabel',xlab) … … 200 202 201 203 def _plot_scans(self, scans, colmode): 202 print " Can only plot one row per scan."204 print "Plotting mode is scans across panels. Can only plot one row per scan." 203 205 if colmode == 's': 204 206 return … … 285 287 self._plotter.plot(x,y,m) 286 288 xlim=[min(x),max(x)] 289 if self._minmaxx is not None: 290 xlim = self._minmaxx 287 291 self._plotter.axes.set_xlim(xlim) 288 292 … … 410 414 self._plotter.plot(x,y,m) 411 415 xlim=[min(x),max(x)] 416 if self._minmaxx is not None: 417 xlim = self._minmaxx 412 418 self._plotter.axes.set_xlim(xlim) 413 419 … … 424 430 Parameters: 425 431 stacking: tell the plotter which variable to plot 426 as line colo ur overlays (default 'pol')432 as line color overlays (default 'pol') 427 433 panelling: tell the plotter which variable to plot 428 434 across multiple panels (default 'scan' … … 510 516 mp: a list of 'strings'. This should have the same length 511 517 as the number of elements on the legend and then maps 512 to the indeces in order 518 to the indeces in order. It is possible to uses latex 519 math expression. These have to be enclosed in r'', e.g. r'$x^{2}$' 513 520 514 521 Example: … … 516 523 for CO and SiO: 517 524 plotter.set_stacking('i') 518 plotter.set_legend _map(['CO','SiO'])525 plotter.set_legend(['CO','SiO']) 519 526 plotter.plot() 527 plotter.set_legend([r'$^{12}CO$', r'SiO']) 520 528 """ 521 529 self._lmap = mp … … 524 532 525 533 def set_title(self, title=None): 534 """ 535 Set the title of the plot. If multiple panels are plotted, 536 multiple titles have to be specified. 537 Example: 538 # two panels are visible on the plotter 539 plotter.set_title(["First Panel","Second Panel"]) 540 """ 526 541 self._title = title 527 542 if self._data: self.plot() … … 529 544 530 545 def set_ordinate(self, ordinate=None): 546 """ 547 Set the y-axis label of the plot. If multiple panels are plotted, 548 multiple labels have to be specified. 549 Example: 550 # two panels are visible on the plotter 551 plotter.set_ordinate(["First Y-Axis","Second Y-Axis"]) 552 """ 531 553 self._ordinate = ordinate 532 554 if self._data: self.plot() … … 534 556 535 557 def set_abcissa(self, abcissa=None): 558 """ 559 Set the x-axis label of the plot. If multiple panels are plotted, 560 multiple labels have to be specified. 561 Example: 562 # two panels are visible on the plotter 563 plotter.set_ordinate(["First X-Axis","Second X-Axis"]) 564 """ 536 565 self._abcissa = abcissa 537 566 if self._data: self.plot() 538 567 return 539 568 569 def set_colors(self, colormap): 570 """ 571 Set the colors to be used. The plotter will cycle through 572 these colors when lines are overlaid (stacking mode). 573 Example: 574 plotter.set_colors("red green blue") 575 # If for example four lines are overlaid e.g I Q U V 576 # 'I' will be 'red', 'Q' will be 'green', U will be 'blue' 577 # and 'V' will be 'red' again. 578 """ 579 self._plotter.palette(0,colormap=colormap) 580 if self._data: self.plot() 581 582 def set_linestyles(self, linestyles): 583 """ 584 Parameters: 585 linestyles: a list of linestyles to use. 586 'line', 'dashed', 'dotted', 'dashdot', 587 'dashdotdot' and 'dashdashdot' are 588 possible 589 590 Set the linestyles to be used. The plotter will cycle through 591 these linestyles when lines are overlaid (stacking mode) AND 592 only one color has been set. 593 Example: 594 plotter.set_colors("black") 595 plotter.set_linestyles("line dashed dotted dashdot") 596 # If for example four lines are overlaid e.g I Q U V 597 # 'I' will be 'solid', 'Q' will be 'dashed', 598 # U will be 'dotted' and 'V' will be 'dashdot'. 599 """ 600 self._plotter.palette(color=0,linestyle=0,linestyles=linestyles) 601 if self._data: self.plot() 602 540 603 def save(self, filename=None, orientation=None): 541 604 """ … … 619 682 dstokes2 = {"I":0,"Plinear":1,"Pangle":2,"V":3} 620 683 draw = {"XX":0, "YY":1,"Real(XY)":2, "Imag(XY)":3} 621 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag e(RL)":3}684 dcirc = { "RR":0,"LL":1}#,"Real(RL)":2,"Imag(RL)":3} 622 685 623 686 if pol is None:
Note:
See TracChangeset
for help on using the changeset viewer.