@@ -7772,13 +7772,15 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
77727772
77737773 Notes
77747774 -----
7775- - Currently ``hist2d`` calculates its own axis limits, and any limits
7776- previously set are ignored.
7777- - Rendering the histogram with a logarithmic color scale is
7778- accomplished by passing a `.colors.LogNorm` instance to the *norm*
7779- keyword argument. Likewise, power-law normalization (similar
7780- in effect to gamma correction) can be accomplished with
7781- `.colors.PowerNorm`.
7775+ Rendering the histogram with a logarithmic color scale is accomplished
7776+ by passing a `.colors.LogNorm` instance to the *norm* keyword
7777+ argument. Likewise, power-law normalization (similar in effect to gamma
7778+ correction) can be accomplished with `.colors.PowerNorm`.
7779+
7780+ .. versionchanged:: 3.11
7781+ Previously, `~.Axes.hist2d` would force the axes limits to match the
7782+ extents of the histogram; now, autoscaling also takes other plot
7783+ elements into account.
77827784 """
77837785
77847786 h , xedges , yedges = np .histogram2d (x , y , bins = bins , range = range ,
@@ -7790,8 +7792,6 @@ def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
77907792 h [h > cmax ] = None
77917793
77927794 pc = self .pcolormesh (xedges , yedges , h .T , ** kwargs )
7793- self .set_xlim (xedges [0 ], xedges [- 1 ])
7794- self .set_ylim (yedges [0 ], yedges [- 1 ])
77957795
77967796 return h , xedges , yedges , pc
77977797
0 commit comments