11
11
from .mpl_axes import Axes
12
12
13
13
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
-
22
14
def _tick_only (ax , bottom_on , left_on ):
23
15
bottom_off = not bottom_on
24
16
left_off = not left_on
@@ -200,9 +192,7 @@ def __init__(self, fig,
200
192
self .set_label_mode (label_mode )
201
193
202
194
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 )
206
196
self ._horiz_pad_size = Size .Fixed (axes_pad [0 ])
207
197
self ._vert_pad_size = Size .Fixed (axes_pad [1 ])
208
198
@@ -265,9 +255,8 @@ def set_axes_pad(self, axes_pad):
265
255
axes_pad : (float, float)
266
256
The padding (horizontal pad, vertical pad) in inches.
267
257
"""
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.
271
260
self ._horiz_pad_size .fixed_size = axes_pad [0 ]
272
261
self ._vert_pad_size .fixed_size = axes_pad [1 ]
273
262
@@ -280,7 +269,8 @@ def get_axes_pad(self):
280
269
hpad, vpad
281
270
Padding (horizontal pad, vertical pad) in inches.
282
271
"""
283
- return self ._axes_pad
272
+ return (self ._horiz_pad_size .fixed_size ,
273
+ self ._vert_pad_size .fixed_size )
284
274
285
275
def set_aspect (self , aspect ):
286
276
"""Set the aspect of the SubplotDivider."""
@@ -423,24 +413,21 @@ def __init__(self, fig,
423
413
424
414
self .ngrids = ngrids
425
415
426
- axes_pad = _extend_axes_pad (axes_pad )
427
- self ._axes_pad = axes_pad
416
+ self ._init_axes_pad (axes_pad )
428
417
429
418
self ._colorbar_mode = cbar_mode
430
419
self ._colorbar_location = cbar_location
431
420
if cbar_pad is None :
432
421
# horizontal or vertical arrangement?
433
422
if cbar_location in ("left" , "right" ):
434
- self ._colorbar_pad = axes_pad [ 0 ]
423
+ self ._colorbar_pad = self . _horiz_pad_size . fixed_size
435
424
else :
436
- self ._colorbar_pad = axes_pad [ 1 ]
425
+ self ._colorbar_pad = self . _vert_pad_size . fixed_size
437
426
else :
438
427
self ._colorbar_pad = cbar_pad
439
428
440
429
self ._colorbar_size = cbar_size
441
430
442
- self ._init_axes_pad (axes_pad )
443
-
444
431
cbook ._check_in_list (["column" , "row" ], direction = direction )
445
432
self ._direction = direction
446
433
@@ -528,7 +515,7 @@ def _update_locators(self):
528
515
529
516
for col , ax in enumerate (self .axes_row [0 ]):
530
517
if h :
531
- h .append (self ._horiz_pad_size ) # Size.Fixed(self._axes_pad))
518
+ h .append (self ._horiz_pad_size )
532
519
533
520
if ax :
534
521
sz = Size .AxesX (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
@@ -559,7 +546,7 @@ def _update_locators(self):
559
546
v_cb_pos = []
560
547
for row , ax in enumerate (self .axes_column [0 ][::- 1 ]):
561
548
if v :
562
- v .append (self ._vert_pad_size ) # Size.Fixed(self._axes_pad))
549
+ v .append (self ._vert_pad_size )
563
550
564
551
if ax :
565
552
sz = Size .AxesY (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
0 commit comments