8000 Backport PR #13989: FIX: update not replace hist_kwargs when density … · matplotlib/matplotlib@d216265 · GitHub
[go: up one dir, main page]

Skip to content

Commit d216265

Browse files
jklymakMeeseeksDev[bot]
authored andcommitted
Backport PR #13989: FIX: update not replace hist_kwargs when density is passed
1 parent b1a6fba commit d216265

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)
0