Skip to content

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

Closed as not planned

Description

@xczics

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

Activity

  1. anntzer commented on Apr 22, 2021

    @anntzer
    Contributor

    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.

  2. timhoffm commented on Apr 22, 2021

    @timhoffm
    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
  3. jklymak commented on Apr 22, 2021

    @jklymak
    Member

    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.

  4. github-actions commented on Dec 13, 2023

    @github-actions

    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!

  5. added
    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.
    on Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    New featurestatus: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Actiontopic: legend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions