Changeset 19424
- Timestamp:
- 07/03/15 06:27:04 (10 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.py
r18558 r19424 2 2 from cmaptools import truncate_colormap 3 3 from plot_contour import plot_contour 4 from expdisp import expdisp 4 5 5 6 try: … … 234 235 cb.set_label(options.getfieldvalue('colorbartitle'),fontsize=fontsize) 235 236 cb.ax.tick_params(labelsize=fontsize) 237 cb.solids.set_rasterized(True) 236 238 cb.update_ticks() 239 cb.set_alpha(1) 240 cb.draw_all() 237 241 plt.sca(ax) # return to original axes control 238 242 #}}} 239 243 244 #expdisp {{{ 245 if options.exist('expdisp'): 246 filename=options.getfieldvalue('expdisp') 247 style=options.getfieldvalue('expstyle','k') 248 linewidth=options.getfieldvalue('explinewidth',1) 249 for i in xrange(len(filename)): 250 filenamei=filename[i] 251 stylei=style[i] 252 if type(linewidth)==list: 253 linewidthi=linewidth[i] 254 else: 255 linewidthi=linewidth 256 expdisp(filenamei,ax,linestyle=stylei,linewidth=linewidthi,unitmultiplier=options.getfieldvalue('unit',1)) 257 #}}} 258 240 259 #area 241 242 #expdisp243 260 244 261 #text {{{ -
issm/trunk-jpl/src/m/plot/plot_manager.py
r17954 r19424 29 29 30 30 'ax' is a handle to the axes instance created by plotmodel. This is 31 currently generated using matplotlib's AxesGrid toolki .31 currently generated using matplotlib's AxesGrid toolkit. 32 32 33 33 Usage: -
issm/trunk-jpl/src/m/plot/plot_overlay.py
r19380 r19424 2 2 from processmesh import processmesh 3 3 from processdata import processdata 4 from xy2ll import xy2ll 4 5 import matplotlib.pyplot as plt 5 6 import matplotlib as mpl 7 from mpl_toolkits.basemap import Basemap 6 8 import os 9 7 10 try: 8 11 from osgeo import gdal 9 12 except ImportError: 10 13 print 'osgeo/gdal for python not installed, plot_overlay is disabled' 14 11 15 12 16 def plot_overlay(md,data,options,ax): … … 78 82 plt.hist(arr.flatten(),bins=256,range=(0.,1.)) 79 83 plt.title('histogram of overlay image, use for setting overlaylims') 84 plt.show() 80 85 plt.sca(ax) # return to original axes/figure 81 86 … … 92 97 yarr=npy.arange(ymin,ymax,-dy) # -dy since origin='upper' (not sure how robust this is) 93 98 xg,yg=npy.meshgrid(xarr,yarr) 94 if options.exist('basemap'):95 # TODO get handle to or create basemap instance96 # create coordinate grid in map projection units (for plotting)97 lats,lons=xy2ll(xg,yg,-1,0,71)98 xgmap,ygmap=m(lons,lats) # map projection units returned by basemap instance99 else:100 xgmap=xg101 ygmap=yg102 103 99 overlaylims=options.getfieldvalue('overlaylims',[min(arr.ravel()),max(arr.ravel())]) 104 105 100 norm=mpl.colors.Normalize(vmin=overlaylims[0],vmax=overlaylims[1]) 106 101 107 pc=ax.pcolormesh(xgmap, ygmap, npy.flipud(arr), cmap=mpl.cm.Greys, norm=norm) 102 if options.exist('basemap'): 103 # create coordinate grid in map projection units (for plotting) 104 lat,lon=xy2ll(xlim,ylim,-1,0,71) 105 #plt.sca(ax) 106 width=xmax-xmin 107 height=ymax-ymin 108 lat_0,lon_0=xy2ll(xmin+width/2.,ymin+height/2.,-1,0,71) 109 m=Basemap(projection='spstere', 110 llcrnrlon=lon[0],llcrnrlat=lat[0],urcrnrlon=lon[1],urcrnrlat=lat[1], 111 epsg=3031, 112 resolution='c') 113 #width=width,height=height,lon_0=lon_0,lat_0=lat_0, 114 #lat_0=-90,lon_0=0,lat_ts=-71, 115 #llcrnrx=x0,llcrnry=y0,urcrnrx=x1,urcrnry=y1) 116 #test 117 #m.ax=ax 118 meridians=npy.arange(-180.,181.,1.) 119 parallels=npy.arange(-80.,80.,1.) 120 m.drawparallels(parallels,labels=[0,0,1,1]) # labels=[left,right,top,bottom] 121 m.drawmeridians(meridians,labels=[1,1,0,0]) 122 m.drawcoastlines() 123 pc=m.pcolormesh(xg, yg, npy.flipud(arr), cmap=mpl.cm.Greys, norm=norm, ax=ax) 124 125 else: 126 pc=ax.pcolormesh(xg, yg, npy.flipud(arr), cmap=mpl.cm.Greys, norm=norm) 127 108 128 #rasterization? 109 129 if options.getfieldvalue('rasterized',0): -
issm/trunk-jpl/src/m/plot/plotmodel.py
r18194 r19424 5 5 import pylab as p 6 6 import matplotlib.pyplot as plt 7 from mpl_toolkits.axes_grid1 import ImageGrid 7 from mpl_toolkits.axes_grid1 import ImageGrid, AxesGrid 8 8 except ImportError: 9 9 print "could not import pylab, matplotlib has not been installed, no plotting capabilities enabled"
Note:
See TracChangeset
for help on using the changeset viewer.