Changeset 1146


Ignore:
Timestamp:
08/16/06 11:35:42 (18 years ago)
Author:
mar637
Message:

added linecatalog plotting; fixed numarray imports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapplotter.py

    r1116 r1146  
    11from asap import rcParams, print_log, selector
    2 from numarray import logical_and
     2from asap import NUM
    33
    44class asapplotter:
     
    1616            self._visible = visible
    1717        self._plotter = self._newplotter()
    18 
    1918
    2019        self._panelling = None
     
    3837        self._selection = selector()
    3938        self._hist = rcParams['plotter.histogram']
    40         from matplotlib import rc as mplrc
    41         mplrc('legend',fontsize=8)
    4239
    4340    def _translate(self, instr):
     
    359356            rcp('font', size=size)
    360357        if self._data: self.plot(self._data)
     358
     359    def plot_lines(self, linecat=None, offset=0.0, peak=5.0, rotate=0.0,
     360                   location=None):
     361        """
     362        """
     363        if not self._data: return
     364        from asap._asap import linecatalog
     365        if not isinstance(linecat, linecatalog): return
     366        if not self._data.get_unit().endswith("GHz"): return
     367        self._plotter.hold()
     368        for j in range(len(self._plotter.subplots)):
     369            self._plotter.subplot(j)
     370            lims = self._plotter.axes.get_xlim()
     371            for i in range(linecat.nrow()):
     372                freq = linecat.get_frequency(i)/1000.0 + offset
     373                if lims[0] < freq < lims[1]:
     374                    if location is None:
     375                        loc = 'bottom'
     376                        if i%2: loc='top'
     377                    else: loc = location
     378                    self._plotter.vline_with_label(freq, peak, linecat.get_name(i),
     379                                             location=loc, rotate=rotate)
     380        self._plotter.release()
    361381
    362382    def save(self, filename=None, orientation=None, dpi=None):
     
    515535                    y = scan._getspectrum(r)
    516536                m = scan._getmask(r)
     537                from matplotlib.numerix import logical_not, logical_and
    517538                if self._maskselection and len(self._usermask) == len(m):
    518539                    if d[self._stacking](r) in self._maskselection[self._stacking]:
    519540                        m = logical_and(m, self._usermask)
    520541                x = scan._getabcissa(r)
    521                 from matplotlib.numerix import ma, logical_not, array
     542                from matplotlib.numerix import ma, array
    522543                y = ma.masked_array(y,mask=logical_not(array(m,copy=False)))
    523544                if self._minmaxx is not None:
     
    540561                plotit = self._plotter.plot
    541562                if self._hist: plotit = self._plotter.hist
    542                 if len(x) > 0: plotit(x,y)
    543                 xlim= self._minmaxx or [min(x),max(x)]
    544                 allxlim += xlim
    545                 ylim= self._minmaxy or [ma.minimum(y),ma.maximum(y)]
    546                 allylim += ylim
     563                if len(x) > 0:
     564                    plotit(x,y)
     565                    xlim= self._minmaxx or [min(x),max(x)]
     566                    allxlim += xlim
     567                    ylim= self._minmaxy or [ma.minimum(y),ma.maximum(y)]
     568                    allylim += ylim
    547569                stackcount += 1
    548570                # last in colour stack -> autoscale x
Note: See TracChangeset for help on using the changeset viewer.