Changeset 17635
- Timestamp:
- 04/03/14 14:57:10 (11 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.py
r17256 r17635 1 import numpy as npy 2 1 3 try: 2 4 from matplotlib.ticker import MaxNLocator … … 153 155 if options.exist('clim'): 154 156 lims=options.getfieldvalue('clim') 157 elif options.exist('caxis'): 158 lims=options.getfieldvalue('caxis') 155 159 if len(lims)!=2: 156 print 'WARNING: clim should be passed as a list of length 2'160 print 'WARNING: clim/caxis should be passed as a list of length 2' 157 161 else: 158 162 p.clim(lims[0],lims[1]) … … 167 171 #}}} 168 172 169 #colormap 173 #colormap {{{ 174 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 175 #}}} 170 176 171 177 #wrapping … … 180 186 cax = divider.new_horizontal("5%", pad=0.05, axes_class=mpl.axes.Axes) 181 187 fig.add_axes(cax) 182 cmap = mpl.cm.jet183 188 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 184 189 cb = mpl.colorbar.ColorbarBase(cax, cmap=cmap, norm=norm) 185 190 else: 186 cb=p.colorbar() 191 # build custom colorbar (does not yet allow customizing the location) 192 fig = p.gcf() 193 ax = p.gca() 194 divider = make_axes_locatable(ax) 195 cax = divider.new_horizontal("5%", pad=0.05, axes_class=mpl.axes.Axes) 196 fig.add_axes(cax) 197 norm = mpl.colors.Normalize(vmin=npy.min(data.flatten()), vmax=npy.max(data.flatten())) 198 cb = mpl.colorbar.ColorbarBase(cax, cmap=cmap, norm=norm) 187 199 cb.locator=MaxNLocator(nbins=5) # default 5 ticks 188 200 cb.update_ticks() -
issm/trunk-jpl/src/m/plot/plot_unit.py
r17203 r17635 2 2 try: 3 3 import pylab as p 4 import matplotlib as mpl 4 5 except ImportError: 5 6 print "could not import pylab, matplotlib has not been installed, no plotting capabilities enabled" … … 21 22 colorlevels=options.getfieldvalue('colorlevels',256) 22 23 24 #colormap 25 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 26 23 27 if datatype==1: 24 28 #element plot … … 32 36 #node plot 33 37 if is2d: 34 p.tricontourf(x,y,elements,data,colorlevels )38 p.tricontourf(x,y,elements,data,colorlevels,cmap=cmap) 35 39 if edgecolor != 'None': 36 40 p.triplot(x,y,elements,color=edgecolor)
Note:
See TracChangeset
for help on using the changeset viewer.