Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A funtion can put text and data legend together in a freedom way. #20045

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

Closed
xczics opened this issue Apr 22, 2021 · 4 comments
Closed

A funtion can put text and data legend together in a freedom way. #20045

xczics opened this issue Apr 22, 2021 · 4 comments
Labels
New feature status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action topic: legend

Comments

@xczics
Copy link

xczics commented Apr 22, 2021

Problem

I want to create a table-like legend looks like:
image
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:
image

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!

Additional context and prior art

@anntzer
Copy link
Contributor

anntzer commented 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
Copy link
Member

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

@jklymak
Copy link
Member

jklymak commented Apr 22, 2021

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.

Copy link

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!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Dec 13, 2023
@github-actions github-actions bot added the status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. label Jan 13, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature status: closed as inactive Issues closed by the "Stale" Github Action. Please comment on any you think should still be open. status: inactive Marked by the “Stale” Github Action topic: legend
Projects
None yet
Development

No branches or pull requests

5 participants