Ignore:
Timestamp:
Jun 14, 2013, 10:10:43 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON planetoplot_v2. added --modx to produce a modulo on x labelling (e.g. for local time plots or Ls plots). thanks Tanguy for the request.

File:
1 edited

Legend:

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

    r990 r991  
    248248    return what_I_plot
    249249
     250# a function to change labels with modulo
     251# ---------------------------------------
     252def labelmodulo(ax,mod):
     253    mpl.draw()
     254    strtab = []
     255    for tick in ax.get_xaxis().get_ticklabels():
     256        num = float(tick.get_text())
     257        strtab.append(num % mod)
     258    ax.get_xaxis().set_ticklabels(strtab)
     259    return ax
     260
    250261# a function to output an ascii file
    251262# ----------------------------------
     
    265276        else:
    266277            print "!! WARNING !! Not printing the file, 2D fields not supported yet."
    267 #    mydata = np.transpose([absc,np.transpose(field)]) #tab
    268 #    for line in mydata:
    269 #        zeline = str(line)
    270 #        zeline = zeline.replace('[','')
    271 #        zeline = zeline.replace(']','')
    272 #        myfile.write(zeline + '\n')
    273278    return
    274279
     
    333338                 colorb="jet",\
    334339                 units="",\
     340                 modx=None,\
    335341                 title=""):
    336342        ## what could be defined by the user
     
    352358        self.units = units
    353359        self.colorb = colorb
     360        self.modx = modx
    354361        ## other useful arguments
    355362        ## ... not used here in ppplot but need to be attached to plot object
     
    505512        else:
    506513            print "!! WARNING. in logx mode, ticks are set automatically."
     514        ## specific modulo labels
     515        if self.modx is not None:
     516            ax = labelmodulo(ax,self.modx)
    507517
    508518################################
Note: See TracChangeset for help on using the changeset viewer.