@@ -263,11 +263,11 @@ def __call__(self, ax, renderer):
263
263
# extend tri/rectangles.
264
264
if self ._cbar .orientation == 'vertical' :
265
265
if aspect :
266
- self ._cbar .set_aspect (aspect * shrink )
266
+ self ._cbar .ax . set_box_aspect (aspect * shrink )
267
267
pos = pos .shrunk (1 , shrink ).translated (0 , offset * pos .height )
268
268
else :
269
269
if aspect :
270
- self ._cbar .set_aspect ( 1 / (aspect / shrink ))
270
+ self ._cbar .ax . set_box_aspect ( 1 / (aspect * shrink ))
271
271
pos = pos .shrunk (shrink , 1 ).translated (offset * pos .width , 0 )
272
272
return pos
273
273
@@ -963,6 +963,7 @@ def set_aspect(self, aspect):
963
963
"""
964
964
Set ratio of the long axis to short axis.
965
965
"""
966
+ self .ax ._colorbar_info ['aspect' ] = aspect
966
967
if self .orientation == 'horizontal' :
967
968
aspect = 1 / aspect
968
969
self .ax .set_box_aspect (aspect )
@@ -1318,7 +1319,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
1318
1319
1319
1320
anchor = kw .pop ('anchor' , loc_settings ['anchor' ])
1320
1321
panchor = kw .pop ('panchor' , loc_settings ['panchor' ])
1321
-
1322
+ aspect0 = aspect
1322
1323
# turn parents into a list if it is not already. We do this w/ np
1323
1324
# because `plt.subplots` can return an ndarray and is natural to
1324
1325
# pass to `colorbar`.
@@ -1376,7 +1377,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
1376
1377
anchor = anchor ,
1377
1378
panchor = panchor ,
1378
1379
fraction = fraction ,
1379
- aspect = aspect ,
1380
+ aspect = aspect0 ,
1380
1381
pad = pad )
1381
1382
# and we need to set the aspect ratio by hand...
1382
1383
cax .set_anchor (anchor )
@@ -1431,6 +1432,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
1431
1432
kw ['orientation' ] = loc_settings ['orientation' ]
1432
1433
location = kw ['ticklocation' ] = loc_settings ['location' ]
1433
1434
1435
+ aspect0 = aspect
1434
1436
anchor = kw .pop ('anchor' , loc_settings ['anchor' ])
1435
1437
panchor = kw .pop ('panchor' , loc_settings ['panchor' ])
1436
1438
pad = kw .pop ('pad' , loc_settings ["pad" ])
@@ -1492,7 +1494,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
1492
1494
anchor = anchor ,
1493
1495
panchor = panchor ,
1494
1496
fraction = fraction ,
1495
- aspect = aspect ,
1497
+ aspect = aspect0 ,
1496
1498
pad = pad )
1497
1499
return cax , kw
1498
1500
0 commit comments