Changeset 17756
- Timestamp:
- 04/17/14 10:46:47 (11 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/m/plot/applyoptions.py ¶
r17706 r17756 1 1 import numpy as npy 2 2 from cmaptools import truncate_colormap 3 from plot_contour import plot_contour 3 4 4 5 try: … … 23 24 #if not isnan(md.mesh.hemisphere): 24 25 # options.addfielddefault('hemisphere',md.mesh.hemisphere) 26 27 # get handle to current figure and axes instance 28 fig = p.gcf() 29 ax=p.gca() 25 30 26 31 #font {{{ … … 113 118 114 119 #ticklabel notation {{{ 115 p.gca().ticklabel_format(style='sci',scilimits=(0,0))120 #ax.ticklabel_format(style='sci',scilimits=(0,0)) 116 121 #}}} 117 122 118 123 #ticklabelfontsize {{{ 119 124 if options.exist('ticklabelfontsize'): 120 ax=p.gca()121 125 for label in ax.get_xticklabels() + ax.get_yticklabels(): 122 126 label.set_fontsize(options.getfieldvalue('ticklabelfontsize')) … … 131 135 if options.exist('axis'): 132 136 if options.getfieldvalue('axis',True)=='off': 133 p.gca().ticklabel_format(style='plain')134 p.setp( p.gca().get_xticklabels(), visible=False)135 p.setp( p.gca().get_yticklabels(), visible=False)137 ax.ticklabel_format(style='plain') 138 p.setp(ax.get_xticklabels(), visible=False) 139 p.setp(ax.get_yticklabels(), visible=False) 136 140 # }}} 137 141 … … 177 181 defaultmap=truncate_colormap(mpl.cm.gnuplot2,0.1,0.9,128) 178 182 cmap=options.getfieldvalue('colormap',defaultmap) 183 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 184 options.addfield('colornorm',norm) 185 cbar_extend=0 186 if options.exist('cmap_set_over'): 187 over=options.getfieldvalue('cmap_set_over','0.5') 188 cmap.set_over(over) 189 cbar_extend+=1 190 if options.exist('cmap_set_under'): 191 under=options.getfieldvalue('cmap_set_under','0.5') 192 cmap.set_under(under) 193 cbar_extend+=2 194 options.addfield('colormap',cmap) 179 195 #}}} 180 196 … … 183 199 #colorbar {{{ 184 200 if options.getfieldvalue('colorbar',1)==1: 185 fig = p.gcf()186 ax = p.gca()187 201 divider = make_axes_locatable(ax) 188 202 cax = divider.new_horizontal("5%", pad=0.05, axes_class=mpl.axes.Axes) 189 203 fig.add_axes(cax) 190 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])191 cbar_extend=0192 if options.exist('cmap_set_over'):193 over=options.getfieldvalue('cmap_set_over','0.5')194 cmap.set_over(over)195 cbar_extend+=1196 if options.exist('cmap_set_under'):197 under=options.getfieldvalue('cmap_set_under','0.5')198 cmap.set_under(under)199 cbar_extend+=2200 204 if cbar_extend==0: 201 205 extend='neither' … … 226 230 #streamlines 227 231 228 #contours 232 #contours {{{ 233 if options.exist('contourlevels'): 234 plot_contour(md,data,options) 235 #}}} 229 236 230 237 #axis positions -
TabularUnified issm/trunk-jpl/src/m/plot/plot_manager.py ¶
r17654 r17756 30 30 #initialize plot handle variable 31 31 handle=None 32 33 # initialize subplot 34 p.subplot(nlines,ncols,i,aspect='equal') 32 35 33 36 ##basemap plot … … 70 73 71 74 #standard plot 72 if not handle:73 p.subplot(nlines,ncols,i,aspect='equal')75 #if not handle: 76 # p.subplot(nlines,ncols,i,aspect='equal') 74 77 75 78 #plot unit -
TabularUnified issm/trunk-jpl/src/m/plot/plot_overlay.py ¶
r17657 r17756 52 52 gtif=gdal.Open(inputname) 53 53 arr=gtif.ReadAsArray() 54 os.system('rm -rf ./temp.tif')54 #os.system('rm -rf ./temp.tif') 55 55 56 56 if gtif.RasterCount>=3: # RGB array … … 62 62 # normalize array 63 63 arr=arr/npy.float(npy.max(arr.ravel())) 64 65 if options.getfieldvalue('overlayhist',0)==1: 66 ax=plt.gca() 67 num=2 68 while True: 69 if not plt.fignum_exists(num): 70 break 71 else: 72 num+=1 73 plt.figure(num) 74 plt.hist(arr.flatten(),bins=256,range=(0.,1.)) 75 plt.title('histogram of overlay image, use for setting overlaylims') 76 plt.sca(ax) # return to original axes/figure 77 64 78 65 79 # get parameters from cropped geotiff … … 89 103 90 104 norm=mpl.colors.Normalize(vmin=overlaylims[0],vmax=overlaylims[1]) 105 91 106 handle.pcolormesh(xgmap, ygmap, npy.flipud(arr), cmap=mpl.cm.Greys, norm=norm) 92 plt.axes().set_aspect('equal','box')107 handle.set_aspect('equal','box') 93 108 return handle -
TabularUnified issm/trunk-jpl/src/m/plot/plotmodel.py ¶
r17698 r17756 56 56 57 57 if not hold: # TODO need to also check whether figurenumber is a new plot so that old plots are not mistakenly cleared 58 p.cl f()58 p.cla() 59 59 60 #TODO fig, axarray = plt.subplots(nrows,ncols), then pass fix and axarr to plot_manager 60 61 #if figsize specified 61 62 if options.list[0].exist('figsize'):
Note:
See TracChangeset
for help on using the changeset viewer.