Skip to content

Conversation

@gapplef
Copy link
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
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
Contributor Author

gapplef commented Dec 17, 2025

Done. @timhoffm

Copy link
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 on lines +1 to +6
Handle single color for multiple datasets in hist
-----------------

It is now possible to use a single color with multiple datasets in ``hist``.
Up to now, the 'color' keyword argument required one color per dataset.
Using a single color with multiple datasets would previously lead to a ValueError.
Copy link
Member

@timhoffm timhoffm Dec 17, 2025

Choose a reason for hiding this comment

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

Suggested change
Handle single color for multiple datasets in hist
-----------------
It is now possible to use a single color with multiple datasets in ``hist``.
Up to now, the 'color' keyword argument required one color per dataset.
Using a single color with multiple datasets would previously lead to a ValueError.
``hist()`` supports a single color for multiple datasets
--------------------------------------------------------
It is now possible pass a single *color* value to `~.Axes.hist()`. This value
is applied to all datasets.

A bit more to the point.

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

2 participants