@@ -1297,20 +1297,37 @@ def get_tightbbox(self, renderer, *args, **kwargs):
1297
1297
self ._tightbbox = bbox
1298
1298
return bbox
1299
1299
1300
- def heatmap (self , * args , ** kwargs ):
1300
+ def heatmap (self , * args , aspect = None , ** kwargs ):
1301
1301
"""
1302
1302
Pass all arguments to `~matplotlib.axes.Axes.pcolormesh` then apply
1303
1303
settings that are suitable for heatmaps: no gridlines, no minor ticks,
1304
1304
and major ticks at the center of each grid box.
1305
+
1306
+ Parameters
1307
+ ----------
1308
+ aspect : {'equal', 'auto'} or float, optional
1309
+ Controls the aspect ratio of the axes. The aspect is of particular
1310
+ relevance for heatmaps since it may distort the heatmap, i.e. a grid box
1311
+ will not be square. This parameter is a shortcut for explicitly calling
1312
+ `~matplotlib.axes.set_aspect`.
1313
+
1314
+ The default is :rc:`image.heatmap`. The options are:
1315
+
1316
+ - ``'equal'``: Ensures an aspect ratio of 1. Grid boxes will be square.
1317
+ - ``'auto'``: The axes is kept fixed and the aspect is adjusted so
1318
+ that the data fit in the axes. In general, this will result in non-square
1319
+ grid boxes.
1305
1320
"""
1306
1321
obj = self .pcolormesh (* args , ** kwargs )
1322
+ aspect = _not_none (aspect , rc ['image.aspect' ])
1307
1323
xlocator , ylocator = None , None
1308
1324
if hasattr (obj , '_coordinates' ):
1309
1325
coords = obj ._coordinates
1310
1326
coords = (coords [1 :, ...] + coords [:- 1 , ...]) / 2
1311
1327
coords = (coords [:, 1 :, :] + coords [:, :- 1 , :]) / 2
1312
1328
xlocator , ylocator = coords [0 , :, 0 ], coords [:, 0 , 1 ]
1313
1329
self .format (
1330
+ aspect = aspect ,
1314
1331
xgrid = False , ygrid = False , xtickminor = False , ytickminor = False ,
1315
1332
xlocator = xlocator , ylocator = ylocator ,
1316
1333
)
0 commit comments