Changeset 17640 for issm/trunk-jpl/src/m/plot/plot_unit.py
- Timestamp:
- 04/03/14 17:22:08 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plot_unit.py
r17635 r17640 7 7 8 8 def plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options): 9 """ 10 PLOT_UNIT - unit plot, display data 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 """ 11 17 12 Usage: 13 plot_unit(x,y,z,elements,data,is2d,isplanet,datatype,options) 18 #edgecolor 19 edgecolor=options.getfieldvalue('edgecolor','None') 20 21 #number of colorlevels for plots 22 colorlevels=options.getfieldvalue('colorlevels',256) 23 24 #colormap 25 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 26 cbar_extend=0 27 if options.exist('cmap_set_over'): 28 over=options.getfieldvalue('cmap_set_over','0.5') 29 cmap.set_over(over) 30 cbar_extend+=1 31 if options.exist('cmap_set_under'): 32 under=options.getfieldvalue('cmap_set_under','0.5') 33 cmap.set_under(under) 34 cbar_extend+=1 14 35 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 #colormap 25 cmap=options.getfieldvalue('colormap',mpl.cm.gnuplot2) 26 27 if datatype==1: 28 #element plot 29 if is2d: 30 p.tripcolor(x,y,elements,data,colorlevels,edgecolors=edgecolor) 31 else: 32 raise ValueError('plot_unit error: 3D element plot not supported yet') 33 return 34 35 elif datatype==2: 36 #node plot 37 if is2d: 38 p.tricontourf(x,y,elements,data,colorlevels,cmap=cmap) 39 if edgecolor != 'None': 40 p.triplot(x,y,elements,color=edgecolor) 41 else: 42 raise ValueError('plot_unit error: 3D node plot not supported yet') 43 return 44 45 elif datatype==3: 46 print 'plot_unit message: quiver plot not implemented yet' 47 return 48 49 elif datatype==4: 50 #P1 patch plot 51 print 'plot_unit message: P1 patch plot not implemented yet' 52 return 53 54 elif datatype==5: 55 print 'plot_unit message: P0 patch plot not implemented yet' 56 return 57 58 else: 36 #normalize colormap if clim/caxis specified 37 if options.exist('clim'): 38 lims=options.getfieldvalue('clim',[min(data),max(data)]) 39 elif options.exist('caxis'): 40 lims=options.getfieldvalue('caxis',[min(data),max(data)]) 41 else: 42 lims=[min(data),max(data)] 43 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 44 if datatype==1: 45 #element plot 46 if is2d: 47 p.tripcolor(x,y,elements,data,colorlevels,edgecolors=edgecolor) 48 else: 49 raise ValueError('plot_unit error: 3D element plot not supported yet') 50 return 51 52 elif datatype==2: 53 #node plot 54 if is2d: 55 p.tricontourf(x,y,elements,data,colorlevels,cmap=cmap,norm=norm) 56 if edgecolor != 'None': 57 p.triplot(x,y,elements,color=edgecolor) 58 else: 59 raise ValueError('plot_unit error: 3D node plot not supported yet') 60 return 61 62 elif datatype==3: 63 print 'plot_unit message: quiver plot not implemented yet' 64 return 65 66 elif datatype==4: 67 #P1 patch plot 68 print 'plot_unit message: P1 patch plot not implemented yet' 69 return 70 71 elif datatype==5: 72 print 'plot_unit message: P0 patch plot not implemented yet' 73 return 74 75 else: 59 76 raise ValueError('datatype=%d not supported' % datatype)
Note:
See TracChangeset
for help on using the changeset viewer.