Changeset 1476 in lmdz_wrf


Ignore:
Timestamp:
Mar 31, 2017, 3:05:59 PM (8 years ago)
Author:
lfita
Message:

Improving 'draw_Nlines':

Adding '*' for no label
Adding 'vrange' for the plot

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1471 r1476  
    21652165    draw_lines(ncfilens, values, varname):
    21662166      ncfilens= [filen] ',' separated list of netCDF files
    2167       values= [dimvname]:[valuesaxis]:[dimtit]:[dimxyfmt]:[leglabels]:[vtit]:[title]:[legvals]:[colns]:[lines]
     2167      values= [dimvname]:[valuesaxis]:[dimtit]:[dimxyfmt]:[vrange]:[leglabels]:[vtit]:[title]:[legvals]:[colns]:[lines]
    21682168       [points]:[lwdths]:[psizes]:[freqv]:[figname]:[graphk]:[close]
    21692169        [dimvname]: ',' list of names of the variable with he values of the common dimension
    21702170        [valuesaxis]: which axis will be used for the values ('x', or 'y')
    2171         [dimtit]: title for the common dimension
     2171        [dimtit]: title for the common dimension ('|' for spaces)
    21722172        [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordx]: format of the values at each axis (or 'auto')
    21732173          [dxs]: style of x-axis ('auto' for 'pretty')
     
    21822182          [Ndy]: Number of ticks at the y-axis ('auto' for 5)
    21832183          [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)
    2184         [leglabels]: ',' separated list of names for the legend ('!' for spaces)
     2184        [vrange]=[ymin],[ymax] range for the plot ('auto' for current range of values)
     2185        [leglabels]: ',' separated list of names for the legend ('!' for spaces, '*' for no label)
    21852186        [vartit]: name of the variable in the graph
    21862187        [title]: title of the plot ('|' for spaces)
     
    22112212        quit()
    22122213
    2213     expectargs = '[dimvname]:[valuesaxis]:[dimtit]:[dimxyfmt]:[leglabels]:[vtit]:' + \
    2214       '[title]:[legvals]:[colns]:[lines]:[points]:[lwdths]:[psizes]:[freqv]:' +      \
     2214    expectargs = '[dimvname]:[valuesaxis]:[dimtit]:[dimxyfmt]:[vrange]:[leglabels]:'+\
     2215      '[vtit]:[title]:[legvals]:[colns]:[lines]:[points]:[lwdths]:[psizes]:[freqv]:'+\
    22152216      '[figname]:[graphk]:[close]'
    22162217    drw.check_arguments(fname,values,expectargs,':')
     
    22192220    dimvnames = values.split(':')[0]
    22202221    valuesaxis = values.split(':')[1]
    2221     dimtit = values.split(':')[2]
     2222    dimtit = values.split(':')[2].replace('|', ' ')
    22222223    dimxyfmt = values.split(':')[3]
    2223     leglabels = gen.latex_text(values.split(':')[4].replace('!',' '))
    2224     vartit = values.split(':')[5]
    2225     title = values.split(':')[6].replace('|',' ')
    2226     legvals = values.split(':')[7]
    2227     colns = gen.str_list(values.split(':')[8], ',')
    2228     lines = gen.str_list(values.split(':')[9], ',')
    2229     points = gen.str_list(values.split(':')[10], '@')
    2230     lwdths = gen.str_list_k(values.split(':')[11], ',', 'R')
    2231     psizes = gen.str_list_k(values.split(':')[12], ',', 'R')
    2232     freqv0 = values.split(':')[13]
    2233     figname = values.split(':')[14]
    2234     graphk = values.split(':')[15]
    2235     close = gen.Str_Bool(values.split(':')[16])
     2224    vrange = values.split(':')[4]
     2225    leglabels = gen.latex_text(values.split(':')[5].replace('!',' '))
     2226    vartit = values.split(':')[6]
     2227    title = values.split(':')[7].replace('|',' ')
     2228    legvals = values.split(':')[8]
     2229    colns = gen.str_list(values.split(':')[9], ',')
     2230    lines = gen.str_list(values.split(':')[10], ',')
     2231    points = gen.str_list(values.split(':')[11], '@')
     2232    lwdths = gen.str_list_k(values.split(':')[12], ',', 'R')
     2233    psizes = gen.str_list_k(values.split(':')[13], ',', 'R')
     2234    freqv0 = values.split(':')[14]
     2235    figname = values.split(':')[15]
     2236    graphk = values.split(':')[16]
     2237    close = gen.Str_Bool(values.split(':')[17])
    22362238
    22372239    Nfiles = len(ncfiles)
     
    23202322    yaxis = [ystyl, yaxf, Nyax, yaxor]
    23212323
    2322     drw.plot_lines(dimvalues, varvalues, valuesaxis, dimtit, xaxis, yaxis,           \
     2324    # range
     2325    if vrange == 'auto':
     2326        rng = None
     2327    else:
     2328        rng = np.array(vrange.split(','), dtype=np.float)
     2329
     2330    drw.plot_lines(dimvalues, varvalues, valuesaxis, dimtit, xaxis, yaxis, rng,      \
    23232331      leglabels.split(','), vartit, varunits, title, locleg, legfontsize, colns,     \
    23242332      lines, points, lwdths, psizes, freqv, figname, graphk, close)
  • trunk/tools/drawing_tools.py

    r1475 r1476  
    58765876    return
    58775877
    5878 def plot_lines(vardv, varvv, vaxis, dtit, xaxv, yaxv, linesn, vtit, vunit, gtit,     \
    5879   gloc, gsiz, cs, ls, ps, ws, ss, fv, fign, kfig, ifclose):
     5878def plot_lines(vardv, varvv, vaxis, dtit, xaxv, yaxv, vrange, linesn, vtit, vunit,   \
     5879  gtit, gloc, gsiz, cs, ls, ps, ws, ss, fv, fign, kfig, ifclose):
    58805880    """ Function to plot a collection of lines
    58815881      vardv= list of set of dimension values
     
    58855885      xaxv= list with the x-axis paramteres [style, format, number and orientation]
    58865886      yaxv= list with the y-axis paramteres [style, format, number and orientation]
    5887       linesn= names for the legend
     5887      vrange= range of values of the plot
     5888      linesn= names for the legend ('*' for no label)
    58885889      vtit= title for the vaxis
    58895890      vunit= units of the vaxis
     
    59175918    dxn = np.min(vardv)
    59185919    dxx = np.max(vardv)
    5919     dyn = np.min(varvv)
    5920     dyx = np.max(varvv)
     5920    if vrange is None:
     5921        dyn = np.min(varvv)
     5922        dyx = np.max(varvv)
     5923    else:
     5924        dyn = vrange[0]
     5925        dyx = vrange[1]
    59215926
    59225927    if xaxv[0] == 'pretty':
     
    59745979    if vaxis == 'x':
    59755980        for il in range(Ntraj):
    5976             plt.plot(varvv[il], vardv[il], lins[il], marker=pts[il],                 \
    5977               linewidth=lws[il], markersize=pss[il], label= linesn[il], color=cols[il])
     5981            if linesn[il] == '*':
     5982                plt.plot(varvv[il], vardv[il], lins[il], marker=pts[il],             \
     5983                  linewidth=lws[il], markersize=pss[il], color=cols[il])
     5984            else:
     5985                plt.plot(varvv[il], vardv[il], lins[il], marker=pts[il],             \
     5986                  linewidth=lws[il], markersize=pss[il], label=linesn[il],           \
     5987                  color=cols[il])
    59785988
    59795989        plt.xlim(dyn,dyx)
     
    59825992    else:
    59835993        for il in range(Ntraj):
    5984             plt.plot(vardv[il], varvv[il], lins[il], marker=pts[il],                 \
    5985               linewidth=lws[il], markersize=pss[il], label= linesn[il], color=cols[il])
     5994            if linesn[il] == '*':
     5995                plt.plot(vardv[il], varvv[il], lins[il], marker=pts[il],             \
     5996                  linewidth=lws[il], markersize=pss[il], color=cols[il])
     5997            else:
     5998                plt.plot(vardv[il], varvv[il], lins[il], marker=pts[il],             \
     5999                  linewidth=lws[il], markersize=pss[il], label=linesn[il],           \
     6000                  color=cols[il])
     6001
    59866002       
    59876003        plt.xlim(dxn,dxx)
Note: See TracChangeset for help on using the changeset viewer.