Skip to content

FIX: update not replace hist_kwargs when density is passed #13989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6686,7 +6686,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,

density = bool(density) or bool(normed)
if density and not stacked:
hist_kwargs = dict(density=density)
hist_kwargs['density'] = density

# List to store all the top coordinates of the histograms
tops = []
Expand Down
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6369,3 +6369,10 @@ def test_hist_nan_data():

assert np.allclose(bins, nanbins)
assert np.allclose(edges, nanedges)


def test_hist_range_and_density():
_, bins, _ = plt.hist(np.random.rand(10), "auto",
range=(0, 1), density=True)
assert bins[0] == 0
assert bins[-1] == 1