Skip to content

DOCS 2D Line label option _nolegend_ is not documented #15770

Closed

Description

@jpeacock29

Bug report

The special value for a 2D Line label _nolegend_ is not documented.

Activity

  1. timhoffm commented on Nov 26, 2019

    @timhoffm
    Member

    I'm not sure if this is intended to be user-facing.

    Also there's more logic involved than just _nolegend_:

    l, = plt.plot([1, 3, 2])
    print(l.get_label())
    l, = plt.plot([1, 3, 2], label=None)
    print(l.get_label())
    l, = plt.plot([1, 3, 2], label='_nolegend_')
    print(l.get_label())
    l, = plt.plot([1, 3, 2], label='_private')
    print(l.get_label())
    l, = plt.plot([1, 3, 2], label='visible')
    print(l.get_label())
    plt.legend()
    

    results in

    _line0
    _line1
    _nolegend_
    _private
    visible
    

    and only visible is part of the legend.

  2. jpeacock29 commented on Nov 26, 2019

    @jpeacock29
    Author

    It seems like these magic parameters should definitely be documented. Could not any user incidentally input these values? Surely they're not common labels, but if some labels are special I would think it should be documented. These are also used as an example and floating around as solutions for adding a line but not listing it on the legend.

  3. ImportanceOfBeingErnest commented on Nov 26, 2019

    @ImportanceOfBeingErnest
    Member

    This was documented in 1.3.1 (https://matplotlib.org/1.3.1/users/legend_guide.html), where it says

    If label attribute is empty string or starts with “_”, those artists will be ignored.

    image

    This got lost in #2442, specifically in 99f325d#diff-52cdf77880da5ac3d7b2712d2d318772L47

    I suspect that this was an unintentional mistake and should be readded.

  4. modified the milestones: v3.1.3, v3.2.0 on Dec 2, 2019
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

    Documentation🌱 Good first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions