1111from .mpl_axes import Axes
1212
1313
14- def _extend_axes_pad (value ):
15- # Check whether a list/tuple/array or scalar has been passed
16- ret = value
17- if not hasattr (ret , "__getitem__" ):
18- ret = (value , value )
19- return ret
20-
21-
2214def _tick_only (ax , bottom_on , left_on ):
2315 bottom_off = not bottom_on
2416 left_off = not left_on
@@ -143,8 +135,7 @@ def __init__(self, fig,
143135 - "1": Only the bottom left axes is labelled.
144136 - "all": all axes are labelled.
145137
146- axes_class : a type that is a subclass of `matplotlib.axes.Axes`, \
147- default: None
138+ axes_class : subclass of `matplotlib.axes.Axes`, default: None
148139 """
149140 self ._nrows , self ._ncols = nrows_ncols
150141
@@ -200,9 +191,7 @@ def __init__(self, fig,
200191 self .set_label_mode (label_mode )
201192
202193 def _init_axes_pad (self , axes_pad ):
203- axes_pad = _extend_axes_pad (axes_pad )
204- self ._axes_pad = axes_pad
205-
194+ axes_pad = np .broadcast_to (axes_pad , 2 )
206195 self ._horiz_pad_size = Size .Fixed (axes_pad [0 ])
207196 self ._vert_pad_size = Size .Fixed (axes_pad [1 ])
208197
@@ -265,9 +254,8 @@ def set_axes_pad(self, axes_pad):
265254 axes_pad : (float, float)
266255 The padding (horizontal pad, vertical pad) in inches.
267256 """
268- self ._axes_pad = axes_pad
269-
270- # These two lines actually differ from ones in _init_axes_pad
257+ # Differs from _init_axes_pad by 1) not broacasting, 2) modifying the
258+ # Size.Fixed objects in-place.
271259 self ._horiz_pad_size .fixed_size = axes_pad [0 ]
272260 self ._vert_pad_size .fixed_size = axes_pad [1 ]
273261
@@ -280,7 +268,8 @@ def get_axes_pad(self):
280268 hpad, vpad
281269 Padding (horizontal pad, vertical pad) in inches.
282270 """
283- return self ._axes_pad
271+ return (self ._horiz_pad_size .fixed_size ,
272+ self ._vert_pad_size .fixed_size )
284273
285274 def set_aspect (self , aspect ):
286275 """Set the aspect of the SubplotDivider."""
@@ -410,8 +399,7 @@ def __init__(self, fig,
410399 cbar_set_cax : bool, default: True
411400 If True, each axes in the grid has a *cax* attribute that is bound
412401 to associated *cbar_axes*.
413- axes_class : a type that is a subclass of `matplotlib.axes.Axes`, \
414- default: None
402+ axes_class : subclass of `matplotlib.axes.Axes`, default: None
415403 """
416404 self ._nrows , self ._ncols = nrows_ncols
417405
@@ -423,24 +411,21 @@ def __init__(self, fig,
423411
424412 self .ngrids = ngrids
425413
426- axes_pad = _extend_axes_pad (axes_pad )
427- self ._axes_pad = axes_pad
414+ self ._init_axes_pad (axes_pad )
428415
429416 self ._colorbar_mode = cbar_mode
430417 self ._colorbar_location = cbar_location
431418 if cbar_pad is None :
432419 # horizontal or vertical arrangement?
433420 if cbar_location in ("left" , "right" ):
434- self ._colorbar_pad = axes_pad [ 0 ]
421+ self ._colorbar_pad = self . _horiz_pad_size . fixed_size
435422 else :
436- self ._colorbar_pad = axes_pad [ 1 ]
423+ self ._colorbar_pad = self . _vert_pad_size . fixed_size
437424 else :
438425 self ._colorbar_pad = cbar_pad
439426
440427 self ._colorbar_size = cbar_size
441428
442- self ._init_axes_pad (axes_pad )
443-
444429 cbook ._check_in_list (["column" , "row" ], direction = direction )
445430 self ._direction = direction
446431
@@ -528,7 +513,7 @@ def _update_locators(self):
528513
529514 for col , ax in enumerate (self .axes_row [0 ]):
530515 if h :
531- h .append (self ._horiz_pad_size ) # Size.Fixed(self._axes_pad))
516+ h .append (self ._horiz_pad_size )
532517
533518 if ax :
534519 sz = Size .AxesX (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
@@ -559,7 +544,7 @@ def _update_locators(self):
559544 v_cb_pos = []
560545 for row , ax in enumerate (self .axes_column [0 ][::- 1 ]):
561546 if v :
562- v .append (self ._vert_pad_size ) # Size.Fixed(self._axes_pad))
547+ v .append (self ._vert_pad_size )
563548
564549 if ax :
565550 sz = Size .AxesY (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
0 commit comments