Skip to content

Handle single color for multiple datasets in hist#30867

Merged
timhoffm merged 11 commits into
matplotlib:mainfrom
gapplef:main
Dec 27, 2025
Merged

Handle single color for multiple datasets in hist#30867
timhoffm merged 11 commits into
matplotlib:mainfrom
gapplef:main

Conversation

@gapplef
Copy link
Copy Markdown
Contributor

@gapplef gapplef commented Dec 16, 2025

PR summary

Close #30857 with minimal change

if mcolors.is_color_like(color):
    color = [color]*nx

If a single valid color is provided, duplicate it to match the size of the dataset.

PR checklist

@timhoffm
Copy link
Copy Markdown
Member

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.

@gapplef
Copy link
Copy Markdown
Contributor Author

gapplef commented Dec 17, 2025

Done. @timhoffm

Copy link
Copy Markdown
Member

@timhoffm timhoffm left a 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?

Comment thread doc/release/next_whats_new/hist_color.rst Outdated
@gapplef
Copy link
Copy Markdown
Contributor Author

gapplef commented Dec 18, 2025

I have add a new test for hist and update the what's news.

Comment thread lib/matplotlib/tests/test_axes.py Outdated
Comment thread lib/matplotlib/tests/test_axes.py Outdated
Copy link
Copy Markdown
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Comment thread doc/release/next_whats_new/hist_color.rst Outdated
@timhoffm timhoffm merged commit 7bbe3b7 into matplotlib:main Dec 27, 2025
32 of 36 checks passed
@QuLogic QuLogic added this to the v3.11.0 milestone Dec 27, 2025
andreas16700 added a commit to andreas16700/matplotlib that referenced this pull request Jan 30, 2026
…color for multiple datasets in hist

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ValueError: The 'color' keyword argument must have one color per dataset

4 participants