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.

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()

1 participant