Changeset 1198 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Oct 18, 2016, 5:22:29 PM (8 years ago)
Author:
lfita
Message:

Using `colorbarvals' (list) to keep all the values for the colorbar in 'draw_2D_shad'
Using `cbarv' (list) to keep all the values for the colorbar in 'plot_2D_shadow'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1160 r1198  
    6262          variable a given value is required (-1, all the length)
    6363        [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)
    64         [dimxyfmt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis
     64        [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordx]: format of the values at each axis (or 'auto')
    6565          [dxs]: style of x-axis ('auto' for 'pretty')
    6666            'Nfix', values computed at even 'Ndx'
    6767            'Vfix', values computed at even 'Ndx' increments
    6868            'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
    69           [dxf]: format of the labels at the x-axis
    70           [Ndx]: Number of ticks at the x-axis
     69          [dxf]: format of the labels at the x-axis ('auto' for '%5g')
     70          [Ndx]: Number of ticks at the x-axis ('auto' for 5)
    7171          [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)
    7272          [dys]: style of y-axis ('auto' for 'pretty')
    73           [dyf]: format of the labels at the y-axis
    74           [Ndy]: Number of ticks at the y-axis
     73          [dyf]: format of the labels at the y-axis ('auto' for '%5g')
     74          [Ndy]: Number of ticks at the y-axis ('auto' for 5)
    7575          [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)
    7676        [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]
     
    9797          [proj]: projection
    9898            * 'cyl', cilindric
    99             * 'lcc', lamvbert conformal
     99            * 'lcc', lambert conformal
    100100          [res]: resolution:
    101101            * 'c', crude
     
    220220
    221221    colbarn, fmtcolbar, colbaror = drw.colorbar_vals(colorbarvals,',')
     222    colormapv = [colbarn, fmtcolbar, colbaror]
    222223
    223224    xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyf,',')
     
    229230
    230231    drw.plot_2D_shadow(valshad, vnamesfig, odimxv, odimyv, odimxu, odimyu, xaxis,    \
    231       yaxis, dimnamesv, colbarn, fmtcolbar, colbaror, shading_nx, varunits, figtitle,\
    232       figkind, revals, mapvalue, close)
     232      yaxis, dimnamesv, colormapv, shading_nx, varunits, figtitle, figkind, revals,  \
     233      mapvalue, close)
    233234
    234235    return
  • trunk/tools/drawing_tools.py

    r1192 r1198  
    39283928
    39293929def plot_2D_shadow(varsv, vnames, dimxv, dimyv, dimxu, dimyu, xaxv, yaxv, dimn,      \
    3930   colorbar, cbarfmt, cbaror, vs, uts, vtit, kfig, reva, mapv, ifclose):
     3930  cbarv, vs, uts, vtit, kfig, reva, mapv, ifclose):
    39313931    """ Adding labels and other staff to the graph
    39323932      varsv= 2D values to plot with shading
     
    39373937      yaxv= list with the y-axis paramteres [style, format, number and orientation]
    39383938      dimn= dimension names to plot
    3939       colorbar= name of the color bar to use
    3940       cbarfmt= format of the numbers in the colorbar
    3941       cbaror= orientation of the colorbar
     3939      cbarv= list with the parameters of the color bar [colorbar, cbarfmt, cbaror]
     3940        colorbar: name of the color bar to use
     3941        cbarfmt: format of the numbers in the colorbar
     3942        cbaror: orientation of the colorbar
    39423943      vs= minmum and maximum values to plot in shadow or:
    39433944        'Srange': for full range
     
    41284129    plt.rc('text', usetex=True)
    41294130
    4130     plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vsend[0], vmax=vsend[1])
    4131     if cbaror == 'horizontal':
    4132         cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
     4131    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vsend[0], vmax=vsend[1])
     4132    if cbarv[2] == 'horizontal':
     4133        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
    41334134        # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib
    41344135        ticklabels= cbar.ax.get_xticklabels()
     
    41384139        cbar.ax.set_xticklabels(ticklabs,rotation=90)
    41394140    else:
    4140         cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
     4141        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
    41414142   
    41424143    if not mapv is None:
    4143         if colorbar == 'gist_gray':
     4144        if cbarv[0] == 'gist_gray':
    41444145            m.drawcoastlines(color="red")
    41454146        else:
     
    41504151        parallels = gen.pretty_int(nlat,xlat,yaxv[2])
    41514152        m.drawparallels(parallels,labels=[False,True,True,False])
    4152 
    4153         print fname + '; Lluis nlat:', nlat, 'xlat:', xlat, 'Ny-axis:',yaxv[2]
    4154         print fname + '; Lluis meridians:', meridians, 'parallels:', parallels
    41554153
    41564154        plt.xlabel('W-E')
Note: See TracChangeset for help on using the changeset viewer.