-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Handle single color for multiple datasets in hist
#30867
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
base: main
Are you sure you want to change the base?
Conversation
|
The code itself is fine. Please update the docstring and ad a release note. See https://matplotlib.org/devdocs/devel/api_changes.html#announce-new-and-deprecated-api. |
|
Done. @timhoffm |
timhoffm
left a comment
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.
Sorry, I forgot to mention: Could you please also add a test?
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
|
I have add a new test for hist and update the what's news. |
| # Test a single color for multiple datasets | ||
| # https://github.com/matplotlib/matplotlib/issues/30857 | ||
| data = [[0, 1, 2], [3, 4, 5]] | ||
| plt.hist(data, color='k') |
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.
This only tests that the call does not blow up. It does not verify whether the right thing happens. Please refine:
| plt.hist(data, color='k') | |
| _, _, bar_containers = plt.hist(data, color='k') | |
| for p in bar_containers[0].patches: | |
| assert mcolor.same_color(p.get_facecolor(), 'k') | |
| for p in bar_containers[1].patches: | |
| assert mcolor.same_color(p.get_facecolor(), 'k') |
| # Test a single color for multiple datasets | ||
| # https://github.com/matplotlib/matplotlib/issues/30857 |
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.
| # Test a single color for multiple datasets | |
| # https://github.com/matplotlib/matplotlib/issues/30857 |
The content of the first line is already expressed through the function name.
We typically do not reference github issues. For future readers, it does not matter whether the test was added as part of the original implementation or through a later issue. If somebody really want to know this they can reconstruct the PR from the commit and the issue from the PR.
PR summary
Close #30857 with minimal change
If a single valid color is provided, duplicate it to match the size of the dataset.
PR checklist