matplotlib / matplotlib/matplotlib
ENH: add entrys to legend explicitly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
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 https://github.com/matplotlib/matplotlib/issues/29422#issuecomment-2576407483_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Legend implementation and the existing plt.plot(label=...) and plt.legend(...) entry points. Trace how handles and labels are stored, then define the behavior for adding an artist after creation and verify that the legend updates for multiple or third-party legends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100