Changeset 26182
- Timestamp:
- 04/08/21 03:48:03 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/plotmodel.py
r25125 r26182 14 14 def plotmodel(md, *args): 15 15 ''' 16 PLOTMODEL - At command prompt, type 'plotdoc()' for additional 16 PLOTMODEL - At command prompt, type 'plotdoc()' for additional 17 17 documentation. 18 18 … … 31 31 subplotwidth = ceil(sqrt(numberofplots)) 32 32 33 # TODO: Check that commenting this out is correct; we do not need a hold 33 # TODO: Check that commenting this out is correct; we do not need a hold 34 34 # under matplotlib, right? 35 35 # … … 40 40 if options.list[0].exist('nrows'): 41 41 nrows = options.list[0].getfieldvalue('nrows') 42 nr = True43 42 else: 44 nrows = np.ceil(numberofplots / subplotwidth) 45 nr = False 43 if options.list[0].exist('ncols'): 44 ncols = options.list[0].getfieldvalue('ncols') 45 nrows = np.ceil(numberofplots / ncols) 46 else: 47 nrows = np.ceil(numberofplots / subplotwidth) 46 48 47 49 if options.list[0].exist('ncols'): 48 50 ncols = options.list[0].getfieldvalue('ncols') 49 n c = True51 nrows = np.ceil(numberofplots / ncols) 50 52 else: 51 53 ncols = int(subplotwidth) 52 nc = False53 54 ncols = int(ncols) 54 55 nrows = int(nrows) 55 56 56 #check that nrows and ncols were given at the same time!57 if nr != nc:58 raise Exception('plotmodel error message: nrows and ncols need to be specified together, or not at all')59 60 57 # Go through plots 61 58 # 62 # NOTE: The following is where Python + matplolib differs substantially in 59 # NOTE: The following is where Python + matplolib differs substantially in 63 60 # implementation and inteface from MATLAB. 64 61 # … … 83 80 plotnum = None 84 81 85 # NOTE: The inline comments for each of the following parameters are 82 # NOTE: The inline comments for each of the following parameters are 86 83 # taken from https://matplotlib.org/api/_as_gen/mpl_toolkits.axes_grid1.axes_grid.ImageGrid.html 87 84 # 88 direction = options.list[0].getfieldvalue('direction', 'row') # {"row", "column"}, default: "row"89 axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25) # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches90 add_all = options.list[0].getfieldvalue('add_all', True) # bool, default: True91 share_all = options.list[0].getfieldvalue('share_all', True) # bool, default: False92 label_mode = options.list[0].getfieldvalue('label_mode', 'L') # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled.85 direction = options.list[0].getfieldvalue('direction', 'row') # {"row", "column"}, default: "row" 86 axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25) # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches 87 add_all = options.list[0].getfieldvalue('add_all', True) # bool, default: True 88 share_all = options.list[0].getfieldvalue('share_all', True) # bool, default: False 89 label_mode = options.list[0].getfieldvalue('label_mode', 'L') # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled. 93 90 94 91 # Translate MATLAB colorbar mode to matplotlib 95 92 # 96 93 # TODO: 97 # - Add 'edge' option (research if there is a corresponding option in 94 # - Add 'edge' option (research if there is a corresponding option in 98 95 # MATLAB)? 99 96 # … … 109 106 raise RuntimeError('plotmodel error: colorbar mode \'{}\' is not a valid option'.format(colorbar)) 110 107 111 cbar_mode = colorbar # {"each", "single", "edge", None }, default: None112 cbar_location = options.list[0].getfieldvalue('colorbarpos', 'right') # {"left", "right", "bottom", "top"}, default: "right"113 cbar_pad = options.list[0].getfieldvalue('colorbarpad', 0.025) # float, default: None114 cbar_size = options.list[0].getfieldvalue('colorbarsize', '5%') # size specification (see Size.from_any), default: "5%"108 cbar_mode = colorbar # {"each", "single", "edge", None }, default: None 109 cbar_location = options.list[0].getfieldvalue('colorbarpos', 'right') # {"left", "right", "bottom", "top"}, default: "right" 110 cbar_pad = options.list[0].getfieldvalue('colorbarpad', 0.025) # float, default: None 111 cbar_size = options.list[0].getfieldvalue('colorbarsize', '5%') # size specification (see Size.from_any), default: "5%" 115 112 116 113 # NOTE: Second parameter is: … … 118 115 # rect(float, float, float, float) or int 119 116 # 120 # The axes position, as a (left, bottom, width, height) tuple or as a 117 # The axes position, as a (left, bottom, width, height) tuple or as a 121 118 # three-digit subplot position code (e.g., "121"). 122 119 #
Note:
See TracChangeset
for help on using the changeset viewer.