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
@@ -200,9 +192,7 @@ def __init__(self, fig,
200192 self .set_label_mode (label_mode )
201193
202194 def _init_axes_pad (self , axes_pad ):
203- axes_pad = _extend_axes_pad (axes_pad )
204- self ._axes_pad = axes_pad
205-
195+ axes_pad = np .broadcast_to (axes_pad , 2 )
206196 self ._horiz_pad_size = Size .Fixed (axes_pad [0 ])
207197 self ._vert_pad_size = Size .Fixed (axes_pad [1 ])
208198
@@ -265,9 +255,8 @@ def set_axes_pad(self, axes_pad):
265255 axes_pad : (float, float)
266256 The padding (horizontal pad, vertical pad) in inches.
267257 """
268- self ._axes_pad = axes_pad
269-
270- # These two lines actually differ from ones in _init_axes_pad
258+ # Differs from _init_axes_pad by 1) not broacasting, 2) modifying the
259+ # Size.Fixed objects in-place.
271260 self ._horiz_pad_size .fixed_size = axes_pad [0 ]
272261 self ._vert_pad_size .fixed_size = axes_pad [1 ]
273262
@@ -280,7 +269,8 @@ def get_axes_pad(self):
280269 hpad, vpad
281270 Padding (horizontal pad, vertical pad) in inches.
282271 """
283- return self ._axes_pad
272+ return (self ._horiz_pad_size .fixed_size ,
273+ self ._vert_pad_size .fixed_size )
284274
285275 def set_aspect (self , aspect ):
286276 """Set the aspect of the SubplotDivider."""
@@ -423,24 +413,21 @@ def __init__(self, fig,
423413
424414 self .ngrids = ngrids
425415
426- axes_pad = _extend_axes_pad (axes_pad )
427- self ._axes_pad = axes_pad
416+ self ._init_axes_pad (axes_pad )
428417
429418 self ._colorbar_mode = cbar_mode
430419 self ._colorbar_location = cbar_location
431420 if cbar_pad is None :
432421 # horizontal or vertical arrangement?
433422 if cbar_location in ("left" , "right" ):
434- self ._colorbar_pad = axes_pad [ 0 ]
423+ self ._colorbar_pad = self . _horiz_pad_size . fixed_size
435424 else :
436- self ._colorbar_pad = axes_pad [ 1 ]
425+ self ._colorbar_pad = self . _vert_pad_size . fixed_size
437426 else :
438427 self ._colorbar_pad = cbar_pad
439428
440429 self ._colorbar_size = cbar_size
441430
442- self ._init_axes_pad (axes_pad )
443-
444431 cbook ._check_in_list (["column" , "row" ], direction = direction )
445432 self ._direction = direction
446433
@@ -528,7 +515,7 @@ def _update_locators(self):
528515
529516 for col , ax in enumerate (self .axes_row [0 ]):
530517 if h :
531- h .append (self ._horiz_pad_size ) # Size.Fixed(self._axes_pad))
518+ h .append (self ._horiz_pad_size )
532519
533520 if ax :
534521 sz = Size .AxesX (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
@@ -559,7 +546,7 @@ def _update_locators(self):
559546 v_cb_pos = []
560547 for row , ax in enumerate (self .axes_column [0 ][::- 1 ]):
561548 if v :
562- v .append (self ._vert_pad_size ) # Size.Fixed(self._axes_pad))
549+ v .append (self ._vert_pad_size )
563550
564551 if ax :
565552 sz = Size .AxesY (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
0 commit comments