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

Fix grouped_bar: legend labels, colors, and hatch handling#30768

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
ilakkmanoharan wants to merge16 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromilakkmanoharan:fix/grouped-bar-legend

Conversation

@ilakkmanoharan
Copy link

PR summary

This pull request fixes issues with the grouped_bar method in Axes related to legend labels, bar colors, and hatch patterns.

Why is this change necessary?

Previously, single labels passed to grouped_bar were not applied to all bars, resulting in empty legends. Additionally, color and hatch patterns were not consistently applied across all grouped bars, and passing label and color twice could cause a TypeError.

What problem does it solve?

Ensures that a single label string propagates to all datasets.
Correctly applies colors and hatch patterns for each bar.
Prevents TypeError when labels or colors are passed multiple times.
Updates tests to verify proper handling of single and multiple labels.

What is the reasoning for this implementation?

By expanding single labels to a list internally and correctly mapping colors and hatches to each dataset, we preserve intuitive usage of grouped_bar and maintain correct legend, color, and hatch behavior without changing the API.

Example usage:

import matplotlib.pyplot as pltimport numpy as npfig, ax = plt.subplots()x = np.arange(2)heights = [np.array([1, 2]), np.array([2, 3])]ax.grouped_bar(    heights,    positions=x,    labels=["dataset1", "dataset2"],    color=["C0", "C1"],    hatch=["//", "xx"])ax.legend()plt.show()

PR checklist

closes [Bug]: grouped_bar can pass label and color twice, causing TypeError#30739

ilakkmanoharanand others added16 commitsNovember 4, 2025 14:10
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
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.

This PR is not properly scoped. It contains the commits from your separate PR on hatch handling, which has nothing to do with#30739.

Please take more care when creating PRs.

@ilakkmanoharan
Copy link
Author

This PR is not properly scoped. It contains the commits from your separate PR on hatch handling, which has nothing to do with#30739.

Please take more care when creating PRs.

Thank you for the feedback, Tim

This PR includes the commits from the hatch-handling PR because the fix also needs to incorporate hatch behavior, just like it does for label and color. Since those hatch-related updates are not yet in main, the work for this issue had to be built on top of that PR. Once the hatch-handling PR is merged, this PR will show only the intended diff.

timhoffm reacted with thumbs up emoji

@timhoffm
Copy link
Member

Thanks for the clarification. For the future, please note such an aspect in the PR message. It's an important piece of information for reviewers.

ilakkmanoharan reacted with thumbs up emoji

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

Reviewers

@timhoffmtimhoffmtimhoffm requested changes

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ilakkmanoharan@timhoffm@story645

[8]ページ先頭

©2009-2025 Movatter.jp