Skip to content

ENH: add entrys to legend explicitly #29446

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

Open
story645 opened this issue Jan 9, 2025 · 1 comment
Open

ENH: add entrys to legend explicitly #29446

story645 opened this issue Jan 9, 2025 · 1 comment

Comments

@story645
Copy link
Member

story645 commented Jan 9, 2025

It'd be nice to be able to register artists with the legend on the fly rather than on creation (plt.plot(label='my-label')) or all at once (plt.legend([h1, h1], ['label1, label2'])). I think this would be helpful for managing multiple legends or to modify a third party legend.

You basically have to add a method Legend.add_entry(handle, label) that properly updates the internal state.

Originally posted by @timhoffm in #29422 (comment)

@story645 story645 changed the title ENH: add entrys to label and update ENH: add entrys to legend on the fly Jan 9, 2025
@story645 story645 changed the title ENH: add entrys to legend on the fly ENH: add entrys to legend explicitly Jan 9, 2025
@timhoffm
Copy link
Member

timhoffm commented Jan 9, 2025

Side note: Likely needs some internal refactoring. We currently know the number of entries when we create the legend, and rely on that static information. There's for some up up-front setup in Legend._init_legend_box. Also auto-positioning is done on __init__ we need to decide whether adding an entry should trigger a new position search.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants