Changeset 1084 for trunk/UTIL


Ignore:
Timestamp:
Oct 29, 2013, 2:22:51 PM (11 years ago)
Author:
aslmd
Message:

planetoplot. now full control on ticks : X Y colorbar. also included a secret XKCD mode for advanced users (thanks to native support in matplotlib 1.3)

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

Legend:

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

    r1054 r1084  
    7272parser.add_option('-U','--units',action='append',dest='units',type="string",default=None,help="units for the field")
    7373parser.add_option('-F','--fmt',action='append',dest='fmt',type="string",default=None,help="values formatting. ex: '%.0f' '%3.1e'")
     74parser.add_option('--xcoeff',action='append',dest='xcoeff',type="float",default=None,help="multiply x axis [not for 2D map]")
     75parser.add_option('--ycoeff',action='append',dest='ycoeff',type="float",default=None,help="multiply y axis [not for 2D map]")
     76parser.add_option('--xmin',action='append',dest='xmin',type="float",default=None,help="min bound x axis [not for 2D map]")
     77parser.add_option('--ymin',action='append',dest='ymin',type="float",default=None,help="min bound y axis [not for 2D map]")
     78parser.add_option('--xmax',action='append',dest='xmax',type="float",default=None,help="max bound x axis [not for 2D map]")
     79parser.add_option('--ymax',action='append',dest='ymax',type="float",default=None,help="max bound y axis [not for 2D map]")
     80parser.add_option('--nxticks',action='append',dest='nxticks',type="float",default=None,help="ticks for x axis [not for 2D map]")
     81parser.add_option('--nyticks',action='append',dest='nyticks',type="float",default=None,help="ticks for y axis [not for 2D map]")
    7482# -- 1D plot
    7583parser.add_option('-L','--linestyle',action='append',dest='linestyle',type="string",default=None,help="[1D] linestyle: '-' '--' '.' '..'")
     
    7886parser.add_option('-S','--superpose',action='store_true',dest='superpose',default=False,help="[1D] use same axis for all plots")
    7987parser.add_option('-E','--legend',action='append',dest='legend',type="string",default=None,help="[1D] legend for line")
    80 parser.add_option('--xcoeff',action='append',dest='xcoeff',type="float",default=None,help="[1D] multiply x axis")
    81 parser.add_option('--ycoeff',action='append',dest='ycoeff',type="float",default=None,help="[1D] multiply y axis")
    82 parser.add_option('--xmin',action='append',dest='xmin',type="float",default=None,help="[1D] min bound x axis")
    83 parser.add_option('--ymin',action='append',dest='ymin',type="float",default=None,help="[1D] min bound y axis")
    84 parser.add_option('--xmax',action='append',dest='xmax',type="float",default=None,help="[1D] max bound x axis")
    85 parser.add_option('--ymax',action='append',dest='ymax',type="float",default=None,help="[1D] max bound y axis")
    8688parser.add_option('--modx',action='append',dest='modx',type="float",default=None,help="[1D] change xticks with a modulo")
    8789# -- 2D plot
     
    9799parser.add_option('--svx',action='store',dest='svx',type="int",default=1,help="Define an abscissa stride on vectors only -- not on field")
    98100parser.add_option('--svy',action='store',dest='svy',type="int",default=1,help="Define an ordinate stride on vectors only -- not on field")
     101parser.add_option('--cbticks',action='append',dest='cbticks',type="float",default=None,help="ticks for colorbar")
    99102###########################
    100103(opt,args) = parser.parse_args()
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r1083 r1084  
    12511251                except: pass
    12521252            ###
     1253            try: self.p[iii].nxticks = opt.nxticks[iii]
     1254            except:
     1255                try: self.p[iii].nxticks = opt.nxticks[0]
     1256                except: pass
     1257            ###
     1258            try: self.p[iii].nyticks = opt.nyticks[iii]
     1259            except:
     1260                try: self.p[iii].nyticks = opt.nyticks[0]
     1261                except: pass
     1262            ###
     1263            try: self.p[iii].cbticks = opt.cbticks[iii]
     1264            except:
     1265                try: self.p[iii].cbticks = opt.cbticks[0]
     1266                except: pass
     1267            ###
    12531268            try: self.p[iii].modx = opt.modx[iii]
    12541269            except:
  • trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py

    r1065 r1084  
    5555# (negative mode)
    5656def_negative = False
     57# (xkcd mode)
     58def_xkcd = False
    5759###############################################
    5860
     
    6668    mpl.rcParams['grid.color'] = 'w'
    6769    mpl.rc('savefig',facecolor='k',edgecolor='k')
     70
     71### settings for xkcd mode (only with matplotlib 1.3)
     72### ... you must have Humori-Sans Font installed
     73if def_xkcd:
     74    mpl.xkcd()
    6875
    6976##########################
     
    363370                 nxticks=10,\
    364371                 nyticks=10,\
     372                 cbticks=None,\
    365373                 title=""):
    366374        ## what could be defined by the user
     
    389397        self.nxticks = nxticks
    390398        self.nyticks = nyticks
     399        self.cbticks = cbticks
    391400        ## other useful arguments
    392401        ## ... not used here in ppplot but need to be attached to plot object
     
    540549        if self.ymax is not None: y2 = self.ymax
    541550        ax.set_ybound(lower=y1,upper=y2)
    542         ## set with .div the number of ticks. (is it better than automatic?)
     551        ## set with .div the number of ticks.
    543552        if not self.logx:
    544             ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) #TBD: with nxticks?
     553            ax.xaxis.set_major_locator(MaxNLocator(self.nxticks))
    545554        else:
    546555            print "!! WARNING. in logx mode, ticks are set automatically."
     556        if not self.logy:
     557            ax.yaxis.set_major_locator(MaxNLocator(self.nyticks))
     558        else:
     559            print "!! WARNING. in logy mode, ticks are set automatically."
    547560        ## specific modulo labels
    548561        if self.modx is not None:
     
    714727            else:
    715728                print "!! WARNING. in logx mode, ticks are set automatically."
     729            if not self.logy:
     730                ax.yaxis.set_major_locator(MaxNLocator(self.nyticks))
     731            else:
     732                print "!! WARNING. in logy mode, ticks are set automatically."
    716733            ## specific modulo labels
    717734            if self.modx is not None:
     
    835852            elif self.proj in ['cyl']: orientation="vertical" ; frac = 0.023 ; pad = 0.03 ; lu = 0.5
    836853            else: orientation = zeorientation ; frac = zefrac ; pad = 0.03 ; lu = 0.5
    837             zelevpal = np.linspace(zevmin,zevmax,num=min([ticks/2+1,21]))
     854            if self.cbticks is None:
     855                self.cbticks = min([ticks/2+1,21])
     856            zelevpal = np.linspace(zevmin,zevmax,num=self.cbticks)
    838857            zecb = mpl.colorbar(fraction=frac,pad=pad,\
    839858                                format=self.fmt,orientation=orientation,\
Note: See TracChangeset for help on using the changeset viewer.