Fix legend settings not preserved when regenerating in Qt dialog#31934
Fix legend settings not preserved when regenerating in Qt dialog#31934M-ndak wants to merge 1 commit into
Conversation
Clone ncols, shadow, fancybox, framealpha, title, loc, mode, borderaxespad and bbox_to_anchor from the existing legend before regenerating, so custom legend state is not discarded. Closes matplotlib#17775
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat for real-time discussion. For details on testing, writing docs, and our review process, please see the developer guide. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
Clone ncols, shadow, fancybox, framealpha, title, loc, mode, borderaxespad and bbox_to_anchor from the existing legend before regenerating, so custom legend state is not discarded.
Closes #17775
PR summary
When the "(Re-)Generate automatic legend" checkbox is used in the Qt
figure options dialog, the existing code only preserved
ncolsanddraggable. All other custom legend settings (shadow, fancybox,framealpha, title, loc, mode, borderaxespad, bbox_to_anchor) were
silently discarded.
This fix reads all relevant properties from the existing legend before
calling
axes.legend()again, so the regenerated legend matches theoriginal state.
Minimum reproducible example:
AI Disclosure
Used Claude (Anthropic) to assist with identifying the correct
attributes to read from the Legend object and to verify the fix
via a test script.
PR checklist