Changeset 1479 in lmdz_wrf


Ignore:
Timestamp:
Mar 31, 2017, 4:20:04 PM (8 years ago)
Author:
lfita
Message:

Improving `draw_points' by adding background color on 'labelled'

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/documentation/plotting/plot_points.html

    r1403 r1479  
    5252    &nbsp;&nbsp;&nbsp;&nbsp;[kindfigure]: kind of figure<BR>
    5353    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'legend': only points in the map with the legend with the names<BR>
    54     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'labelled',[txtsize],[txtcol]: points with the names and size, color of text<BR>
     54    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'labelled',[txtsize],[txtcol],[txtbckgcol]: points with the names and size, color of text and background <BR>
     55    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color ('None' for without)<BR>
    5556    &nbsp;&nbsp;&nbsp;&nbsp;[pointcolor]: color for the points ('auto' for "red")<BR>
    5657    &nbsp;&nbsp;&nbsp;&nbsp;[pointlabels]: ',' of labels [only used if [collab]='None'] ('None' for no labels, '!' for spaces)<BR>
     
    8788    </DIV>
    8889    <DIV CLASS="valins">
    89       $ python ${pyHOME}/drawing.py -o draw_points -S 'SuperStorm/tslist.dat,#,3,2,1:SuperStorm|sfc|stations:auto:cyl,i:labelled,10,r:auto:None:0:png:stations_loc:True' -f 'geo_em.d02.nc,XLONG_M,XLAT_M,HGT_M,Time|0@west_east|30;180;1@south_north|175;255;1,height,0.,1500.,terrain,auto,auto,m'
     90      $ python ${pyHOME}/drawing.py -o draw_points -S 'SuperStorm/tslist.dat,#,3,2,1:SuperStorm|sfc|stations:auto:cyl,i:labelled,10,r,None:auto:None:0|12:png:stations_loc:True' -f 'geo_em.d02.nc,XLONG_M,XLAT_M,HGT_M,Time|0@west_east|30;180;1@south_north|175;255;1,height,0.,1500.,terrain,auto,auto,m'
    9091    </DIV>
    9192  </BODY>
  • trunk/tools/drawing.py

    r1476 r1479  
    30163016        [kindfigure]: kind of figure
    30173017          'legend': only points in the map with the legend with the names
    3018           'labelled',[txtsize],[txtcol]: points with the names and size, color of text
     3018          'labelled',[txtsize],[txtcol],[txtbckgcol]: points with the names and size, color of text and background
     3019            color ('None' for without)
    30193020        [pointcolor]: color for the points ('auto' for "red")
    30203021        [pointlabels]: ',' of labels [only used if [collab]='None'] ('None' for no labels, '!' for spaces)
     
    30583059
    30593060    expectargs = '[ptasciifile]:[gtit]:[dimxyfmt]:[mapvalues]:[kindfigure]:' +       \
    3060       '[pointcolor]:[pointlabels]:[locleg]:[figurek]:[figuren]:[close]'
     3061      '[pointcolor]:[pointlabels]:[legvals]:[figurek]:[figuren]:[close]'
    30613062 
    30623063    drw.check_arguments(fname,values,expectargs,':')
     
    30693070    pointcolor = values.split(':')[5]
    30703071    pointlabels = values.split(':')[6].replace('!',' ')
    3071     locleg = int(values.split(':')[7])
     3072    legvalues = values.split(':')[7]
    30723073    figureko = values.split(':')[8]
    30733074    figuren = values.split(':')[9]
     
    32333234        mapV = mapvalues
    32343235
     3236    # legend
     3237    locleg, sizeleg = drw.legend_values(legvalues, '|')
     3238
    32353239    drw.plot_points(xptval, yptval, lonv, latv, varextra, varextrav, gtit, xaxis,    \
    3236       yaxis, mapV, kindfigure, pointcolor, ptlabels, locleg, figureko, figuren, close)
     3240      yaxis, mapV, kindfigure, pointcolor, ptlabels, locleg, sizeleg, figureko,      \
     3241      figuren, close)
    32373242
    32383243    onc.close()
  • trunk/tools/drawing_tools.py

    r1476 r1479  
    30043004
    30053005def plot_points(xval, yval, vlon, vlat, extravals, extrapar, vtit, xaxv, yaxv, mapv, \
    3006   figk, color, labels, lloc, kfig, figname, ifclose):
     3006  figk, color, labels, lloc, gsize, kfig, figname, ifclose):
    30073007    """ plotting points
    30083008      [x/yval]: x,y values to plot
     
    30313031      labels= list of labels for the points (None, no labels)
    30323032      lloc = localisation of the legend
     3033      gsize = font size of the legend
    30333034      kfig= kind of figure (jpg, pdf, png)
    30343035      figname= name of the figure
     
    31003101    dimyT = dimyT0
    31013102
    3102 # Canging line kinds every 7 pts (end of standard colors)
     3103# Changing line kinds every 7 pts (end of standard colors)
    31033104    ptkinds=['.','x','o','*','+','8','>','D','h','p','s']
    31043105
     
    31743175# Extra values
    31753176    if extravals is not None:
     3177        if len(extravals.shape) != 2:
     3178            print errormsg
     3179            print '  ' + fname + ': extravalues must be 2-rank !!'
     3180            print '    given shape:', extravals.shape
     3181            quit(-1)
     3182
    31763183        plt.pcolormesh(x, y, extravals, cmap=plt.get_cmap(extrapar[3]),              \
    31773184          vmin=extrapar[1], vmax=extrapar[2])
     
    31913198
    31923199    if labels is not None:
    3193         for iv in range(len(xval)):
    3194             if np.mod(iv,7) == 0: N7pts = N7pts + 1
    3195 #            print iv,xval[iv],yval[iv],labels[iv],ptkinds[N7pts]
    3196             plt.plot(xval[iv],yval[iv], ptkinds[N7pts],label=labels[iv])
    3197 
    31983200        if figk[0:8] == 'labelled':
    3199             if len(figk.split(',')) != 3:
     3201            if len(figk.split(',')) != 4:
    32003202                print errormsg
    3201                 print '  ' + fname + ": 'labelled' requires two additional values !!"
    3202                 print "    'labelled',[txtsize],[txtcolor]"
     3203                print '  ' + fname + ": 'labelled' requires three additional values !!"
     3204                print "    'labelled',[txtsize],[txtcolor],[txtbckgcolor]"
    32033205                quit(-1)
    32043206            txtsize=int(figk.split(',')[1])
    32053207            txtcol=figk.split(',')[2]
     3208            bcktxtcol=figk.split(',')[3]
     3209            if bcktxtcol != 'None':
     3210                for iv in range(len(xval)):
     3211                    plt.annotate(labels[iv], xy=(xval[iv],yval[iv]), xycoords='data',\
     3212                      fontsize=txtsize, color=txtcol, backgroundcolor=bcktxtcol,     \
     3213                      zorder=2)
     3214            else:
     3215                for iv in range(len(xval)):
     3216                    plt.annotate(labels[iv], xy=(xval[iv],yval[iv]), xycoords='data',\
     3217                      fontsize=txtsize, color=txtcol, zorder=2)
    32063218            for iv in range(len(xval)):
    3207                 plt.annotate(labels[iv], xy=(xval[iv],yval[iv]), xycoords='data',    \
    3208                   fontsize=txtsize, color=txtcol)
    3209         elif figk == 'legend':
    3210             plt.legend(loc=lloc)
     3219                if np.mod(iv,7) == 0: N7pts = N7pts + 1
     3220                plt.plot(xval[iv],yval[iv], ptkinds[N7pts], color=txtcol, zorder=3)
     3221        elif figk[0:6]== 'legend':
     3222            for iv in range(len(xval)):
     3223                if np.mod(iv,7) == 0: N7pts = N7pts + 1
     3224                plt.plot(xval[iv],yval[iv], ptkinds[N7pts], label=labels[iv])
     3225            plt.legend(loc=lloc, prop={'size':gsize})
    32113226
    32123227    else:
Note: See TracChangeset for help on using the changeset viewer.