-
Notifications
You must be signed in to change notification settings - Fork 18
Sync _legend_dict on legend location change
#310
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
needs tests |
2005c9e to
77be15e
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a synchronization issue where _legend_dict becomes out of sync when legend locations are changed after creation. The fix involves creating a custom Legend class that overrides the set_loc method to update the internal dictionary when the location changes.
- Creates a custom Legend wrapper class that inherits from matplotlib's Legend
- Overrides the
set_locmethod to sync location changes with_legend_dict - Updates all references throughout the codebase to use the new custom Legend class
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| ultraplot/legend.py | Introduces new Legend class with overridden set_loc method for syncing location changes |
| ultraplot/axes/base.py | Updates imports and references to use the custom Legend class instead of matplotlib's Legend |
Comments suppressed due to low confidence (1)
ultraplot/legend.py:33
- The variable name
typeshadows the built-intypefunction. Consider renaming it tolegend_typeor similar.
where, type = old_loc
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2f88207 to
b8c5aba
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
An issue popped up in #309 where if locations are changed for legends they are not synced with
_legend_dict. This PR fixes this by override theset_locfunction of legend.Why was this an issue? UltraPlot allows for updating the styling of legends when a legend already exists on at that location. Since the internal reference is used, a sync issue appears if for whatever reason the legend is moved.