Skip to content

Automatic inference for semantic legends for marker/scatter size#749

Draft
cvanelteren wants to merge 2 commits into
Ultraplot:mainfrom
cvanelteren:hotfix/semantic-legends-alignment
Draft

Automatic inference for semantic legends for marker/scatter size#749
cvanelteren wants to merge 2 commits into
Ultraplot:mainfrom
cvanelteren:hotfix/semantic-legends-alignment

Conversation

@cvanelteren

@cvanelteren cvanelteren commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

How about this @gepcel ?

This PR makes sizelegend line up with scatter marker sizing without forcing users to manually reconstruct UltraPlot’s size-scaling rules. Scatter collections now retain their effective size-scale metadata, and sizelegend() can reuse that information by default to infer matching legend marker sizes from an existing compatible scatter plot, while still allowing explicit overrides and preserving direct area=True / area=False behavior when requested. The change also adds regression coverage for absolute- size, scaled-size, compatibility fallback, and explicit override cases so the legend behavior stays predictable.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ultraplot/legend.py 87.50% 4 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@cvanelteren

Copy link
Copy Markdown
Collaborator Author

@gepcel

ax.plot(..., m='.', ms=50) creates a Line2D point with marker '.' and markersize=50, but your sizelegend([50, 25], area=False) is building semantic legend entries with the default marker 'o'. Numerically the first legend handle is 50 pt, but it is marker='o', not marker='.', so it renders differently and looks wrong for that plot.

@gepcel

gepcel commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

@gepcel

ax.plot(..., m='.', ms=50) creates a Line2D point with marker '.' and markersize=50, but your sizelegend([50, 25], area=False) is building semantic legend entries with the default marker 'o'. Numerically the first legend handle is 50 pt, but it is marker='o', not marker='.', so it renders differently and looks wrong for that plot.

Oh, despite using matplotlib for a long time, I didn't realize '.' and 'o' are different markers. I mistakenly thought they were the same. My bad! Sorry to bother.

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