Changeset 1027 for trunk/UTIL


Ignore:
Timestamp:
Sep 2, 2013, 4:21:01 PM (11 years ago)
Author:
aslmd
Message:

PYTHON planetoplot_v2. possibility to invert xaxis if xmin>xmax. added modulo and more ticks for xlabel non-projected 2d plots

Location:
trunk/UTIL/PYTHON/planetoplot_v2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r1007 r1027  
    262262    strtab = []
    263263    for tick in ax.get_xaxis().get_ticklabels():
    264         num = float(tick.get_text())
    265         strtab.append(num % mod)
     264        onetick = tick.get_text()
     265        if len(onetick) > 0:
     266          num = float(onetick)
     267          strtab.append(num % mod)
    266268    ax.get_xaxis().set_ticklabels(strtab)
    267269    return ax
     
    490492        else:
    491493            mpl.plot(x,y,marker=self.marker,label=self.label)
     494        # AXES
     495        ax = mpl.gca()
    492496        # make log axes and/or invert ordinate
    493497        # ... this must be after plot so that axis bounds are well-defined
     
    495499        if self.logx: mpl.xscale("log") # not mpl.semilogx() because excludes log on y
    496500        if self.logy: mpl.yscale("log") # not mpl.semilogy() because excludes log on x
    497         if self.invert: ax = mpl.gca() ; ax.set_ylim(ax.get_ylim()[::-1])
     501        if self.invert: ax.set_ylim(ax.get_ylim()[::-1])
     502        if self.xmin is not None and self.xmax is not None:
     503          if self.xmin > self.xmax:
     504            ax.set_xlim(ax.get_xlim()[::-1])
     505            self.xmin,self.xmax = self.xmax,self.xmin
    498506        # add a label for line(s)
    499507        if self.label is not None:
    500508            if self.label != "":
    501509                mpl.legend(loc="best",fancybox=True)
    502         # AXES
    503         ax = mpl.gca()
    504510        # format labels
    505511        if self.swap: ax.xaxis.set_major_formatter(FormatStrFormatter(self.fmt))
     
    670676            if self.logy: mpl.semilogy()
    671677            if self.invert: ax.set_ylim(ax.get_ylim()[::-1])
     678            if self.xmin is not None and self.xmax is not None:
     679              if self.xmin > self.xmax:
     680                ax.set_xlim(ax.get_xlim()[::-1])
     681                self.xmin,self.xmax = self.xmax,self.xmin
    672682            if self.xmin is not None: ax.set_xbound(lower=self.xmin)
    673683            if self.xmax is not None: ax.set_xbound(upper=self.xmax)
    674684            if self.ymin is not None: ax.set_ybound(lower=self.ymin)
    675685            if self.ymax is not None: ax.set_ybound(upper=self.ymax)
     686            # set the number of ticks (hardcoded)
     687            ax.xaxis.set_major_locator(MaxNLocator(10))
     688            ## specific modulo labels
     689            if self.modx is not None:
     690                ax = labelmodulo(ax,self.modx)
    676691        else:
    677692            ## A 2D MAP USING PROJECTIONS (basemap)
  • trunk/UTIL/PYTHON/planetoplot_v2/set_ppclass.txt

    r1008 r1027  
    1010  # z-axis: possible names to search for. add in the line with a separating ;
    1111  #
    12 altitude;Alt;presnivs;bottom_top;altitude_abg;lev;PTOT;vert
     12altitude;Alt;presnivs;bottom_top;altitude_abg;lev;PTOT;vert;p
    1313  # t-axis: possible names to search for. add in the line with a separating ;
    1414  #
Note: See TracChangeset for help on using the changeset viewer.