-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add optional bihistogram parameter to plt.hist() #27180
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
I think this is a better candidate for an example than an API expansion, setting the import numpy as np
import matplotlib.pyplot as plt
data1 = np.random.poisson(10, 2000)
data2 = np.random.poisson(20, 1000)
fig, ax = plt.subplots()
ax.hist(data1, bins=np.arange(40), label="Before")
ax.hist(data2, weights=-np.ones_like(data2), bins=np.arange(40), label="After")
ax.axhline(0, color="k")
ax.legend()
fig.savefig("test.png") |
Ah, that's beautiful and far simpler. Heh, kicking myself for not seeing that earlier. Thanks! |
@i-jey would you be interested in adding Kyle's solution to maybe https://matplotlib.org/devdocs/gallery/statistics/histogram_features.html#sphx-glr-gallery-statistics-histogram-features-py as an example of using weights? |
@story645 for sure! I’ll get to that today evening :) |
PR summary
This PR adds an optional boolean parameter to
plt.hist()
,bihist
to enable plotting bihistograms.Bihistograms are one way to visualize an effect on a distribution in a pre-post analysis, making it easier to see changes in the distribution's mean and skew.
PR checklist