Changeset 1123 in lmdz_wrf
- Timestamp:
- Sep 30, 2016, 4:47:55 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1120 r1123 56 56 draw_2D_shad(ncfile, values, varn) 57 57 ncfile= file to use 58 values=[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colorbar ]:[fmtcolorbar]:[sminv],[smaxv]:[figt]:58 values=[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colorbarvals]:[sminv],[smaxv]:[figt]: 59 59 [kindfig]:[reverse]:[mapv]:[close] 60 60 [vnamefs]: Name in the figure of the variable to be shaded … … 62 62 variable a given value is required (-1, all the length) 63 63 [dimx/yvn]: name of the variables with the values of the final dimensions (x,y) 64 [colbarn]: name of the color bar 65 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g) 64 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation] 65 [colorbarn]: name of the color bar 66 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g) 67 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal') 66 68 [smin/axv]: minimum and maximum value for the shading or: 67 69 'Srange': for full range … … 101 103 quit() 102 104 103 expectargs = '[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colbar n]:[fmtcolorbar]:' +\105 expectargs = '[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colbarvals]:' + \ 104 106 '[sminv],[smaxv]:[figt]:[kindfig]:[reverse]:[mapv]:[close]' 105 107 … … 110 112 vdimxn = values.split(':')[2] 111 113 vdimyn = values.split(':')[3] 112 colbarn = values.split(':')[4] 113 fmtcolbar0 = values.split(':')[5] 114 shadminmax = values.split(':')[6] 115 figtitle = values.split(':')[7].replace('|',' ') 116 figkind = values.split(':')[8] 117 revals = values.split(':')[9] 118 mapvalue = values.split(':')[10] 119 close = gen.Str_Bool(values.split(':')[11]) 114 colorbarvals = values.split(':')[4] 115 shadminmax = values.split(':')[5] 116 figtitle = values.split(':')[6].replace('|',' ') 117 figkind = values.split(':')[7] 118 revals = values.split(':')[8] 119 mapvalue = values.split(':')[9] 120 close = gen.Str_Bool(values.split(':')[10]) 120 121 121 122 ncfiles = ncfile … … 224 225 if mapvalue == 'None': mapvalue = None 225 226 227 colbarn = colorbarvals.split(',')[0] 228 fmtcolbar0 = colorbarvals.split(',')[1] 229 colbaror0 = colorbarvals.split(',')[2] 230 226 231 if fmtcolbar0 == 'auto': 227 fmtcolorbar = '%6g' 228 else: 229 fmtcolorbar = fmtcolbar0 232 fmtcolbar = '%6g' 233 else: 234 fmtcolbar = fmtcolbar0 235 if colbaror0 == 'auto': 236 colbaror = 'vertical' 237 else: 238 colbaror = colbaror0 239 230 240 231 241 drw.plot_2D_shadow(valshad, vnamesfig, odimxv, odimyv, odimxu, odimyu, dimnamesv,\ 232 colbarn, fmtcol orbar, shading_nx, varunits, figtitle, figkind, revals,\242 colbarn, fmtcolbar, colbaror, shading_nx, varunits, figtitle, figkind, revals, \ 233 243 mapvalue, close) 234 244 -
trunk/tools/drawing_tools.py
r1120 r1123 3777 3777 3778 3778 def plot_2D_shadow(varsv,vnames,dimxv,dimyv,dimxu,dimyu,dimn, \ 3779 colorbar,cbarfmt, vs,uts,vtit,kfig,reva,mapv,ifclose):3779 colorbar,cbarfmt,cbaror,vs,uts,vtit,kfig,reva,mapv,ifclose): 3780 3780 """ Adding labels and other staff to the graph 3781 3781 varsv= 2D values to plot with shading … … 3786 3786 colorbar= name of the color bar to use 3787 3787 cbarfmt= format of the numbers in the colorbar 3788 cbaror= orientation of the colorbar 3788 3789 vs= minmum and maximum values to plot in shadow or: 3789 3790 'Srange': for full range … … 4001 4002 4002 4003 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vsend[0], vmax=vsend[1]) 4003 cbar = plt.colorbar(format=cbarfmt) 4004 if cbaror == 'horizontal': 4005 cbar = plt.colorbar(format=cbarfmt,orientation=cbaror) 4006 # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib 4007 ticklabels= cbar.ax.get_xticklabels() 4008 Nticks = len(ticklabels) 4009 ticklabs = [] 4010 for itick in range(Nticks): ticklabs.append(ticklabels[itick].get_text()) 4011 cbar.ax.set_xticklabels(ticklabs,rotation=90) 4012 else: 4013 cbar = plt.colorbar(format=cbarfmt,orientation=cbaror) 4014 4004 4015 4005 4016 if not mapv is None:
Note: See TracChangeset
for help on using the changeset viewer.