Skip to content

Expose handles for shared windrose legends - #363

Open
h55n wants to merge 1 commit into
python-windrose:mainfrom
h55n:fix-shared-legend-handles
Open

h55n wants to merge 1 commit into
python-windrose:mainfrom
h55n:fix-shared-legend-handles

Conversation

@h55n

@h55n h55n commented Nov 16, 2026

Copy link
Copy Markdown

Fixes #293.

get_legend_handles_labels() currently returns no windrose bin entries, so the shared figure legend in the issue's example is empty.

Reuse the existing bin handles and label formatting for this method. It returns the windrose bins followed by any ordinary labeled Matplotlib artists, without creating or replacing an axes legend. Decimal places and units are supported, and existing axes legends keep the same output.

Tested:

  • Seven regression cases fail on unchanged upstream, then pass with the fix.
  • All 42 tests pass on Ubuntu (Python 3.11 and 3.15), Windows and macOS (Python 3.15).
  • The full Matplotlib image-comparison run passes on both Ubuntu versions.
  • Documentation, notebook execution, link check, sdist/wheel build, manifest and Twine checks pass.
  • Changed-file pre-commit hooks pass.

The fork test run also corrects the Ubuntu runner condition so its image-comparison steps actually run. That workflow-only adjustment is not part of this PR. Docs and packaging use the same source and tests.

Before:
Two windrose plots without a shared legend

After:
The same plots with a shared four-bin legend

Keep axes legends unchanged while making bin handles and labels
available through the standard Matplotlib axes method. Preserve
formatting, colors and additional labeled artists.

Fixes python-windrose#293.
@ocefpaf

ocefpaf commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

I don't speak for the whole project, just for myself. But as a brown South American climate scientist I will not review or merge any "AI" PRs like this one. It is against everything I believe.

@jkittner

Copy link
Copy Markdown
Contributor

Was my thought too. Basically AI-slop. I would be in favor of closing.

@h55n

h55n commented Nov 16, 2026

Copy link
Copy Markdown
Author

thanks for taking a look, this was for #293 where there was no way to get the legend handles from a shared legend, i reproduced it, added the accessor and covered it with tests that pass on the full suite, i get it if it's not a fit for the project and i'm fine with whatever you decide

This branch has not been deployed

No deployments
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.

Legend handles and lables are not available via ax.get_legend_handles_labels()

3 participants