Changeset 23670 for issm/trunk-jpl/src/py3/plot/plotmodel.py
- Timestamp:
- 01/31/19 07:34:11 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/py3/plot/plotmodel.py
r21255 r23670 1 import numpy as np1 import numpy as np 2 2 from plotoptions import plotoptions 3 from plotdoc import plotdoc 4 from plot_manager import plot_manager 5 from math import ceil, sqrt 3 6 4 7 try: … … 6 9 import matplotlib.pyplot as plt 7 10 from mpl_toolkits.axes_grid1 import ImageGrid, AxesGrid 11 from mpl_toolkits.mplot3d import Axes3D 8 12 except ImportError: 9 13 print("could not import pylab, matplotlib has not been installed, no plotting capabilities enabled") 10 14 11 from plot_manager import plot_manager12 from math import ceil, sqrt13 14 15 def plotmodel(md,*args): 15 ''' 16 at command prompt, type 'plotdoc' for additional documentation 16 ''' at command prompt, type 'plotdoc()' for additional documentation 17 17 ''' 18 18 19 #First process options 19 #First process options 20 20 options=plotoptions(*args) 21 21 22 22 #get number of subplots 23 23 subplotwidth=ceil(sqrt(options.numberofplots)) 24 25 24 #Get figure number and number of plots 26 25 figurenumber=options.figurenumber … … 37 36 nrows=np.ceil(numberofplots/subplotwidth) 38 37 nr=False 39 38 40 39 if options.list[0].exist('ncols'): 41 40 ncols=options.list[0].getfieldvalue('ncols') … … 46 45 ncols=int(ncols) 47 46 nrows=int(nrows) 48 47 49 48 #check that nrows and ncols were given at the same time! 50 49 if not nr==nc: 51 50 raise Exception('error: nrows and ncols need to be specified together, or not at all') 52 51 53 52 #Go through plots 54 53 if numberofplots: 55 56 54 #if plt.fignum_exists(figurenumber): 57 55 # plt.cla() … … 60 58 if options.list[0].exist('figsize'): 61 59 figsize=options.list[0].getfieldvalue('figsize') 62 fig=plt.figure(figurenumber,figsize=(figsize[0],figsize[1]) ,tight_layout=True)60 fig=plt.figure(figurenumber,figsize=(figsize[0],figsize[1]))#,tight_layout=True) 63 61 else: 64 fig=plt.figure(figurenumber ,tight_layout=True)62 fig=plt.figure(figurenumber)#,tight_layout=True) 65 63 fig.clf() 66 64 65 backgroundcolor=options.list[0].getfieldvalue('backgroundcolor',(0.7,0.7,0.7)) 66 fig.set_facecolor(backgroundcolor) 67 68 69 translator={'on':'each', 70 'off':'None', 71 'one':'single'} 67 72 # options needed to define plot grid 73 plotnum=options.numberofplots 68 74 direction=options.list[0].getfieldvalue('direction','row') # row,column 69 75 axes_pad=options.list[0].getfieldvalue('axes_pad',0.25) 70 76 add_all=options.list[0].getfieldvalue('add_all',True) # True,False 71 77 share_all=options.list[0].getfieldvalue('share_all',True) # True,False 72 label_mode=options.list[0].getfieldvalue('label_mode','1') # 1,L,all 73 cbar_mode=options.list[0].getfieldvalue('cbar_mode','each') # none,single,each 74 cbar_location=options.list[0].getfieldvalue('cbar_location','right') # right,top 75 cbar_size=options.list[0].getfieldvalue('cbar_size','5%') 76 cbar_pad=options.list[0].getfieldvalue('cbar_pad','2.5%') # None or % 77 78 axgrid=ImageGrid(fig, 111, 78 label_mode=options.list[0].getfieldvalue('label_mode','L') # 1,L,all 79 colorbar=options.list[0].getfieldvalue('colorbar','on') # on, off (single) 80 cbar_mode=translator[colorbar] 81 cbar_location=options.list[0].getfieldvalue('colorbarpos','right') # right,top 82 cbar_size=options.list[0].getfieldvalue('colorbarsize','5%') 83 cbar_pad=options.list[0].getfieldvalue('colorbarpad','2.5%') # None or % 84 85 axgrid=ImageGrid(fig,111, 79 86 nrows_ncols=(nrows,ncols), 87 ngrids=plotnum, 80 88 direction=direction, 81 89 axes_pad=axes_pad, … … 86 94 cbar_location=cbar_location, 87 95 cbar_size=cbar_size, 88 cbar_pad=cbar_pad 89 ) 96 cbar_pad=cbar_pad) 90 97 91 if cbar_mode=='none': 92 for ax in axgrid.cbar_axes: fig._axstack.remove(ax) 98 if cbar_mode=='None': 99 for ax in axgrid.cbar_axes: 100 fig._axstack.remove(ax) 93 101 94 for i in range(numberofplots): 95 plot_manager(options.list[i].getfieldvalue('model',md),options.list[i],fig,axgrid[i]) 96 102 for i,ax in enumerate(axgrid.axes_all): 103 plot_manager(options.list[i].getfieldvalue('model',md),options.list[i],fig,axgrid,i) 97 104 fig.show() 98 105 else:
Note:
See TracChangeset
for help on using the changeset viewer.