Skip to content

Feature: semantic legend API and geo legend support#586

Open
cvanelteren wants to merge 18 commits intomainfrom
feature/semantic-legend
Open

Feature: semantic legend API and geo legend support#586
cvanelteren wants to merge 18 commits intomainfrom
feature/semantic-legend

Conversation

@cvanelteren
Copy link
Collaborator

@cvanelteren cvanelteren commented Feb 14, 2026

This PR combines the #570/#571 groundwork into a user-facing semantic legend API on Axes (cat_legend, size_legend, num_legend, geo_legend) and wires defaults through rc so behavior is configurable consistently. It also adds geometry-aware legend handling (including country shorthand, projection/resolution/territory controls, and unified handle sizing), plus tests to cover shorthand loc behavior and geo legend rendering paths.

@cvanelteren cvanelteren requested a review from gepcel February 14, 2026 21:17
Move semantic legends into Axes and UltraLegend methods: ax.cat_legend, ax.size_legend, ax.num_legend, ax.geo_legend. Route these methods through Axes.legend so shorthand legend locations (for example loc=r) work consistently.\n\nAdd rc-backed semantic defaults under legend.cat.*, legend.size.*, legend.num.*, and legend.geo.*.\n\nExpand geo legend behavior with country_reso (10m/50m/110m), country_territories toggle, country_proj support (name/CRS/callable), and per-entry tuple overrides for projections/options.\n\nImprove country shorthand handling for legends by preserving nearby islands while pruning far territories by default, with explicit opt-in to include far territories.\n\nAdd regression and feature tests covering shorthand locations, rc defaults, country resolution/projection passthrough, geometry handling, and semantic legend smoke behavior. Legend test suite passes locally.
Add a dedicated semantic legends section to the colorbars/legends guide with working examples for ax.cat_legend, ax.size_legend, ax.num_legend, and ax.geo_legend. The geo example now demonstrates generic polygons, country shorthand, and per-entry tuple overrides for country projection/resolution options. Also clean up the narrative text and convert the snippet into executable notebook cells.
@cvanelteren cvanelteren force-pushed the feature/semantic-legend branch from a31cab1 to ffaaea1 Compare February 14, 2026 21:25
@gepcel
Copy link
Collaborator

gepcel commented Feb 15, 2026

Seems that cat_legend, size_legend, num_legend, geo_legend take label="Legend" as legend title. I suggest it only accepts title= .... Because label and labels easly to get confused. Not easy to tell difference with all arg and it 's plura.

@cvanelteren
Copy link
Collaborator Author

Agreed. The paths look a bit funky with the default lw=1.0 but this is something that happens on the geometry backend.

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.

2 participants