Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle single color for multiple datasets inhist#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
gapplef wants to merge7 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromgapplef:main

Conversation

@gapplef
Copy link
Contributor

@gapplefgapplef commentedDec 16, 2025
edited
Loading

PR summary

Close#30857 with minimal change

ifmcolors.is_color_like(color):color= [color]*nx

If a single validcolor 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. Seehttps://matplotlib.org/devdocs/devel/api_changes.html#announce-new-and-deprecated-api.

@gapplef
Copy link
ContributorAuthor

Done.@timhoffm

Copy link
Member

@timhoffmtimhoffm 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?

@gapplef
Copy link
ContributorAuthor

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')
Copy link
Member

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:

Suggested change
plt.hist(data,color='k')
_,_,bar_containers=plt.hist(data,color='k')
forpinbar_containers[0].patches:
assertmcolor.same_color(p.get_facecolor(),'k')
forpinbar_containers[1].patches:
assertmcolor.same_color(p.get_facecolor(),'k')

Comment on lines +2584 to +2585
# Test a single color for multiple datasets
# https://github.com/matplotlib/matplotlib/issues/30857
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# 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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@timhoffmtimhoffmtimhoffm left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

2 participants

@gapplef@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp