Changeset 17698
- Timestamp:
- 04/09/14 17:14:47 (11 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.py
r17640 r17698 1 1 import numpy as npy 2 from cmaptools import truncate_colormap 2 3 3 4 try: … … 173 174 174 175 #colormap {{{ 175 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 176 # default sequential colormap 177 defaultmap=truncate_colormap(mpl.cm.gnuplot2,0.1,0.9,128) 178 cmap=options.getfieldvalue('colormap',defaultmap) 176 179 #}}} 177 180 -
issm/trunk-jpl/src/m/plot/plot_unit.py
r17691 r17698 1 1 from cmaptools import truncate_colormap 2 2 try: 3 3 import pylab as p … … 7 7 8 8 def plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options): 9 """ 10 PLOT_UNIT - unit plot, display data 11 12 Usage: 13 plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options) 14 15 See also: PLOTMODEL, PLOT_MANAGER 16 """ 17 18 #edgecolor 19 edgecolor=options.getfieldvalue('edgecolor','None') 20 21 #number of colorlevels for plots 22 colorlevels=options.getfieldvalue('colorlevels',256) 23 24 alpha=options.getfieldvalue('alpha',1) 25 26 #colormap 27 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 28 if options.exist('cmap_set_over'): 29 over=options.getfieldvalue('cmap_set_over','0.5') 30 cmap.set_over(over) 31 if options.exist('cmap_set_under'): 32 under=options.getfieldvalue('cmap_set_under','0.5') 33 cmap.set_under(under) 34 35 #normalize colormap if clim/caxis specified 36 if options.exist('clim'): 37 lims=options.getfieldvalue('clim',[min(data),max(data)]) 38 elif options.exist('caxis'): 39 lims=options.getfieldvalue('caxis',[min(data),max(data)]) 40 else: 41 lims=[min(data),max(data)] 42 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 43 if datatype==1: 44 #element plot 45 if is2d: 46 p.tripcolor(x,y,elements,data,colorlevels,cmap=cmap,edgecolors=edgecolor) 47 else: 48 raise ValueError('plot_unit error: 3D element plot not supported yet') 49 return 50 51 elif datatype==2: 52 #node plot 53 if is2d: 54 p.tricontourf(x,y,elements,data,colorlevels,cmap=cmap,norm=norm,alpha=alpha) 55 if edgecolor != 'None': 56 p.triplot(x,y,elements,color=edgecolor) 57 else: 58 raise ValueError('plot_unit error: 3D node plot not supported yet') 59 return 60 61 elif datatype==3: 62 print 'plot_unit message: quiver plot not implemented yet' 63 return 64 65 elif datatype==4: 66 #P1 patch plot 67 print 'plot_unit message: P1 patch plot not implemented yet' 68 return 69 70 elif datatype==5: 71 print 'plot_unit message: P0 patch plot not implemented yet' 72 return 73 74 else: 9 """ 10 PLOT_UNIT - unit plot, display data 11 12 Usage: 13 plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options) 14 15 See also: PLOTMODEL, PLOT_MANAGER 16 """ 17 18 #edgecolor 19 edgecolor=options.getfieldvalue('edgecolor','None') 20 21 #number of colorlevels for plots 22 colorlevels=options.getfieldvalue('colorlevels',256) 23 24 alpha=options.getfieldvalue('alpha',1) 25 26 #colormap 27 # default sequential colormap 28 defaultmap=truncate_colormap(mpl.cm.gnuplot2,0.1,0.9,128) 29 cmap=options.getfieldvalue('colormap',defaultmap) 30 if options.exist('cmap_set_over'): 31 over=options.getfieldvalue('cmap_set_over','0.5') 32 cmap.set_over(over) 33 if options.exist('cmap_set_under'): 34 under=options.getfieldvalue('cmap_set_under','0.5') 35 cmap.set_under(under) 36 37 #normalize colormap if clim/caxis specified 38 if options.exist('clim'): 39 lims=options.getfieldvalue('clim',[min(data),max(data)]) 40 elif options.exist('caxis'): 41 lims=options.getfieldvalue('caxis',[min(data),max(data)]) 42 else: 43 lims=[min(data),max(data)] 44 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 45 if datatype==1: 46 #element plot 47 if is2d: 48 p.tripcolor(x,y,elements,data,colorlevels,cmap=cmap,edgecolors=edgecolor) 49 else: 50 raise ValueError('plot_unit error: 3D element plot not supported yet') 51 return 52 53 elif datatype==2: 54 #node plot 55 if is2d: 56 p.tricontourf(x,y,elements,data,colorlevels,cmap=cmap,norm=norm,alpha=alpha) 57 if edgecolor != 'None': 58 p.triplot(x,y,elements,color=edgecolor) 59 else: 60 raise ValueError('plot_unit error: 3D node plot not supported yet') 61 return 62 63 elif datatype==3: 64 print 'plot_unit message: quiver plot not implemented yet' 65 return 66 67 elif datatype==4: 68 #P1 patch plot 69 print 'plot_unit message: P1 patch plot not implemented yet' 70 return 71 72 elif datatype==5: 73 print 'plot_unit message: P0 patch plot not implemented yet' 74 return 75 76 else: 75 77 raise ValueError('datatype=%d not supported' % datatype) -
issm/trunk-jpl/src/m/plot/plotmodel.py
r17617 r17698 55 55 #handling the 'visible' option will need some check on whether ipython is currently in interactive or non-interactive mode 56 56 57 if not hold: 57 if not hold: # TODO need to also check whether figurenumber is a new plot so that old plots are not mistakenly cleared 58 58 p.clf() 59 59 -
issm/trunk-jpl/src/m/plot/processdata.py
r17696 r17698 46 46 if npy.any(npy.isnan(procdata)): 47 47 procdata[npy.isnan(procdata)]=nanfill 48 options.addfielddefault('cmap_set_under','1') 49 options.addfielddefault('clim',[min(data),max(data)]) 48 50 print "WARNING: nan's treated as -9999 by default. Change using pairoption 'nan',nan_fill_value in plotmodel call" 49 51
Note:
See TracChangeset
for help on using the changeset viewer.