Skip to content

[ENH]: Set color of legend shadow #24663

Closed

Description

@oscargus

Problem

There was a PR to set the shadow color for legend which is now closed: #18668

Proposed solution

Revive that PR. The fair thing to do is to add a Co-authored-by with the original author even if it looks like you will have to copy-and-paste the code. (If you rewrite it independently, there is of course no need to do that.)

Note that there are still some review comments left to handle.

Activity

  1. tuncbkose commented on Dec 8, 2022

    @tuncbkose
    Contributor

    I was thinking of reviving the linked PR, but I saw something that confused me a bit.
    In a code like ax.legend(shadow="y") should "y" be interpreted as "yellow" or True (as in yes)?

    More generally, in test_rcparams.py, there are some expressions (under validate_bool) that presumably should be accepted as booleans:

    ('t', 'y', 'yes', 'on', 'true', '1', 1, True)
    ('f', 'n', 'no', 'off', 'false', '0', 0, False)
    

    Is there a principled way to check if a shadow argument is one of these beyond just copy-pasting the tuple? Or is something like

    if is_color_like(shadow):
        ...
    elif shadow in ('t', 'y', 'yes', 'on', 'true', '1', 1, True):
        ...
    elif shadow in ('f', 'n', 'no', 'off', 'false', '0', 0, False):
        pass
    else:
        raise ValueError('shadow must be a valid color or bool')
    

    good enough?

  2. oscargus commented on Dec 8, 2022

    @oscargus
    MemberAuthor

    I believe that one should differentiate between the rcparams and passing the argument to legend.

    For rcparams there will indeed be a bit of a clash for 'y' and, I think, 1 and 0. Can be worthwhile noting this in the docs.

    For legend=..., only True/False are valid, so there it shouldn't be a problem.

    I think the current code deals with it quite OK, but one should probably document the possible clashes somewhere and how it behaves.

  3. anntzer commented on Dec 8, 2022

    @anntzer
    Contributor

    I think deprecating the interpretation of t/f/y/n as bools in rcparams would be reasonable too.

  4. linked a pull request that will close this issueSetting color of legend shadow #24666on Dec 23, 2022
  5. Shikharishere commented on Feb 17, 2023

    @Shikharishere

    is this issue still open? If yes I would like take it.......

  6. tuncbkose commented on Feb 17, 2023

    @tuncbkose
    Contributor

    There is already some work done and discussion in the linked pull request. I was hoping to finish it next week but feel free to help if you'd like.

  7. added this to the v3.8.0 milestone on Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions