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
@@ -143,8 +135,7 @@ def __init__(self, fig,
143
135
- "1": Only the bottom left axes is labelled.
144
136
- "all": all axes are labelled.
145
137
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
148
139
"""
149
140
self ._nrows , self ._ncols = nrows_ncols
150
141
@@ -200,9 +191,7 @@ def __init__(self, fig,
200
191
self .set_label_mode (label_mode )
201
192
202
193
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 )
206
195
self ._horiz_pad_size = Size .Fixed (axes_pad [0 ])
207
196
self ._vert_pad_size = Size .Fixed (axes_pad [1 ])
208
197
@@ -265,9 +254,8 @@ def set_axes_pad(self, axes_pad):
265
254
axes_pad : (float, float)
266
255
The padding (horizontal pad, vertical pad) in inches.
267
256
"""
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.
271
259
self ._horiz_pad_size .fixed_size = axes_pad [0 ]
272
260
self ._vert_pad_size .fixed_size = axes_pad [1 ]
273
261
@@ -280,7 +268,8 @@ def get_axes_pad(self):
280
268
hpad, vpad
281
269
Padding (horizontal pad, vertical pad) in inches.
282
270
"""
283
- return self ._axes_pad
271
+ return (self ._horiz_pad_size .fixed_size ,
272
+ self ._vert_pad_size .fixed_size )
284
273
285
274
def set_aspect (self , aspect ):
286
275
"""Set the aspect of the SubplotDivider."""
@@ -410,8 +399,7 @@ def __init__(self, fig,
410
399
cbar_set_cax : bool, default: True
411
400
If True, each axes in the grid has a *cax* attribute that is bound
412
401
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
415
403
"""
416
404
self ._nrows , self ._ncols = nrows_ncols
417
405
@@ -423,24 +411,21 @@ def __init__(self, fig,
423
411
424
412
self .ngrids = ngrids
425
413
426
- axes_pad = _extend_axes_pad (axes_pad )
427
- self ._axes_pad = axes_pad
414
+ self ._init_axes_pad (axes_pad )
428
415
429
416
self ._colorbar_mode = cbar_mode
430
417
self ._colorbar_location = cbar_location
431
418
if cbar_pad is None :
432
419
# horizontal or vertical arrangement?
433
420
if cbar_location in ("left" , "right" ):
434
- self ._colorbar_pad = axes_pad [ 0 ]
421
+ self ._colorbar_pad = self . _horiz_pad_size . fixed_size
435
422
else :
436
- self ._colorbar_pad = axes_pad [ 1 ]
423
+ self ._colorbar_pad = self . _vert_pad_size . fixed_size
437
424
else :
438
425
self ._colorbar_pad = cbar_pad
439
426
440
427
self ._colorbar_size = cbar_size
441
428
442
- self ._init_axes_pad (axes_pad )
443
-
444
429
cbook ._check_in_list (["column" , "row" ], direction = direction )
445
430
self ._direction = direction
446
431
@@ -528,7 +513,7 @@ def _update_locators(self):
528
513
529
514
for col , ax in enumerate (self .axes_row [0 ]):
530
515
if h :
531
- h .append (self ._horiz_pad_size ) # Size.Fixed(self._axes_pad))
516
+ h .append (self ._horiz_pad_size )
532
517
533
518
if ax :
534
519
sz = Size .AxesX (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
@@ -559,7 +544,7 @@ def _update_locators(self):
559
544
v_cb_pos = []
560
545
for row , ax in enumerate (self .axes_column [0 ][::- 1 ]):
561
546
if v :
562
- v .append (self ._vert_pad_size ) # Size.Fixed(self._axes_pad))
547
+ v .append (self ._vert_pad_size )
563
548
564
549
if ax :
565
550
sz = Size .AxesY (ax , aspect = "axes" , ref_ax = self .axes_all [0 ])
0 commit comments