Skip to content

Commit 3d302d6

Browse files
authored
Merge pull request matplotlib#13990 from meeseeksmachine/auto-backport-of-pr-13989-on-v3.1.x
Backport PR matplotlib#13989 on branch v3.1.x (FIX: update not replace hist_kwargs when density is passed)
2 parents b1a6fba + d216265 commit 3d302d6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6732,7 +6732,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67326732

67336733
density = bool(density) or bool(normed)
67346734
if density and not stacked:
6735-
hist_kwargs = dict(density=density)
6735+
hist_kwargs['density'] = density
67366736

67376737
# List to store all the top coordinates of the histograms
67386738
tops = []

lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6367,3 +6367,10 @@ def test_hist_nan_data():
63676367

63686368
assert np.allclose(bins, nanbins)
63696369
assert np.allclose(edges, nanedges)
6370+
6371+
6372+
def test_hist_range_and_density():
6373+
_, bins, _ = plt.hist(np.random.rand(10), "auto",
6374+
range=(0, 1), density=True)
6375+
assert bins[0] == 0
6376+
assert bins[-1] == 1

0 commit comments

Comments
 (0)