Changeset 204 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Dec 9, 2014, 5:30:58 PM (10 years ago)
Author:
lfita
Message:

Adding legend position in 'draw_lines_time'

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r203 r204  
    15781578    draw_lines_time(ncfilens, values, varname):
    15791579      ncfilens= [filen] ',' separated list of netCDF files
    1580       values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[timevals];[graphk]
     1580      values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[timevals];[locleg];[graphk]
    15811581        [dimvname]: name of the variable with he values of the common dimension
    15821582        [valuesaxis]: which axis will be used for the values ('x', or 'y')
     
    15961596                'l': milisecond
    15971597           [tfmt]; desired format
     1598        [locleg]: location of the legend (-1, autmoatic)
     1599          1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
     1600          5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     1601          9: 'upper center', 10: 'center'
    15981602        [graphk]: kind of the graphic
    15991603      varname= variable to plot
    1600       values= 'time;y;time ([DD]${[HH]}$);32x32;$wss^{*}$;wss Taylor's turbulence term;time|hours!since!1949-12-01_00:00:00;exct,12,h|%d$^{%H}$;pdf'
     1604      values= 'time;y;time ([DD]${[HH]}$);32x32;$wss^{*}$;wss Taylor's turbulence term;time|hours!since!1949-12-01_00:00:00;exct,12,h|%d$^{%H}$;2;pdf'
    16011605    """
    16021606
     
    16091613
    16101614    expectargs = '[dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];'
    1611     expectargs = expectargs + '[timevals];[graphk]'
     1615    expectargs = expectargs + '[timevals];[locleg];[graphk]'
    16121616    drw.check_arguments(fname,len(expectargs.split(';')),values,';',expectargs)
    16131617
     
    16201624    title = values.split(';')[5].replace('|',' ')
    16211625    timevals = values.split(';')[6]
    1622     graphk = values.split(';')[7]
     1626    locleg = int(values.split(';')[7])
     1627    graphk = values.split(';')[8]
    16231628
    16241629    Nfiles = len(ncfiles)
     
    17021707
    17031708    drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit, leglabels.split(','),   \
    1704       vartit, varunits, timepos, timelabels, title, graphk)
     1709      vartit, varunits, timepos, timelabels, title, locleg, graphk)
    17051710
    17061711    return
  • trunk/tools/drawing_tools.py

    r197 r204  
    44614461
    44624462def plot_lines_time(vardv, varvv, vaxis, dtit, linesn, vtit, vunit, tpos, tlabs,     \
    4463   gtit, kfig):
     4463  gtit, gloc, kfig):
    44644464    """ Function to plot a collection of lines with a time axis
    44654465      vardv= list of set of dimension values
     
    44734473      tlabs= labels of the time ticks
    44744474      gtit= main title
     4475      gloc= location of the legend (-1, autmoatic)
     4476        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
     4477        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     4478        9: 'upper center', 10: 'center'
    44754479      kfig= kind of figure
    44764480      plot_lines([np.arange(10)], [np.sin(np.arange(10)*np.pi/2.5)], 'y', 'time (s)',      \
     
    45254529
    45264530    plt.title(graphtit)
    4527     plt.legend()
     4531    plt.legend(loc=gloc)
    45284532   
    45294533    output_kind(kfig, figname, True)
  • trunk/tools/nc_var_tools.py

    r200 r204  
    84618461            newval = True
    84628462    elif vtype == '|S1':
    8463         newval = val
    8464     elif vtype == 'str':
    8465         print val, type(val)
    8466         newval = str(val)
     8463        newval = char(val)
    84678464    else:
    84688465        print errormsg
Note: See TracChangeset for help on using the changeset viewer.