You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A funtion can put text and data legend together in a freedom way. #20045
I want to create a table-like legend looks like:
To complete this, we may need a new feature that can put text and legend together by pharsing text.
If we can write "10℃\t20℃\t30℃\t\n<line1>\t<line2>\t<line3>\tPhlo..." to complete this, we may create more wonderful lengends!
Here is a sample image of what I am asking for:
Proposed Solution
We can get a legend handle for most Artists and we can layout text relative to other artists. We just need a function put those two features together!
I am almost certain there was a request some time ago to be able to have e.g. ylabels of the form <the line> label (basically, moving the legend for an axes with a single artist to the ylabel). Likely the discussions should be linked...
Semi-related: Markers on axis (#16005), but this uses dedicated methods set_xlabel_legend().
I see the appeal of embedding markers in Text via placeholders.
Implementation-wise this needs a bit more thought:
Can we embed that into existing Text objects cleanly? Probably not because i) API-wise we have to pass the markers, ii) implementation-wise the rendering/layout algorithm would become much more complex.
Can we make a proxy Artist, that takes the string and markers and breaks it in howmany Text objects we need and lays them out all together? This does not quite feel how we usually operate, OTOH we have some "collection" Artists.
Can we make a dedicated Text subclass that has the additional features? Maybe
legend has already solved all this with a hierarchy of hbox and vbox packers, similar to the TeX basic objects. i.e. https://matplotlib.org/stable/api/offsetbox_api.html#matplotlib.offsetbox.HPacker I think if you want a custom 4-column legend, its just a matter of laterally laying out 3 lines instead of just one. I would not be in favour of expanding the legend API to make that happen, but the tools are all there to write your own legend_4col.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Activity
anntzer commentedon Apr 22, 2021
I am almost certain there was a request some time ago to be able to have e.g. ylabels of the form
<the line> label(basically, moving the legend for an axes with a single artist to the ylabel). Likely the discussions should be linked...Edit: @timhoffm found it below, it's #16005.
timhoffm commentedon Apr 22, 2021
Semi-related: Markers on axis (#16005), but this uses dedicated methods
set_xlabel_legend().I see the appeal of embedding markers in Text via placeholders.
Implementation-wise this needs a bit more thought:
Textobjects cleanly? Probably not because i) API-wise we have to pass the markers, ii) implementation-wise the rendering/layout algorithm would become much more complex.Textobjects we need and lays them out all together? This does not quite feel how we usually operate, OTOH we have some "collection" Artists.Textsubclass that has the additional features? Maybejklymak commentedon Apr 22, 2021
legendhas already solved all this with a hierarchy of hbox and vbox packers, similar to the TeX basic objects. i.e. https://matplotlib.org/stable/api/offsetbox_api.html#matplotlib.offsetbox.HPacker I think if you want a custom 4-column legend, its just a matter of laterally laying out 3 lines instead of just one. I would not be in favour of expanding the legend API to make that happen, but the tools are all there to write your ownlegend_4col.github-actions commentedon Dec 13, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!