Skip to content

Only one legend entry is rendered for items with the same label and color #10056

@gpelouze

Description

@gpelouze

Only one legend entry is rendered for items with the same label and color

In Matplotlib 2.1.1, items that have the same label and color result in a single legend entry. This happens even if some other properties of the items are different (eg. marker or linewidth).

This behaviour is surprising because the style of the first item is used for the handle, regardless of the style of the following items.

I would expect either the behaviour from Matplotlib 2.1.0, or the labels being merged only if the label and all style properties are equal.

Code for reproduction

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
plt.plot([0, 1], [0, 1], label='foo', color='k', marker='o', linewidth=1)
plt.plot([0, 1], [1, 2], label='foo', color='k', marker='.', linewidth=2)
plt.plot([0, 1], [2, 3], label='bar', color='k', marker='s', linewidth=3)
plt.legend()
plt.savefig('foobar.png')

Actual outcome (Matplotlib 2.1.1)

foobar_211

Expected outcome (Matplotlib 2.1.0)

foobar_210

Matplotlib version

  • Operating system: Arch Linux
  • Matplotlib version: 2.1.1
  • Matplotlib backend: agg
  • Python version: 3.6.3
  • Matplotlib installed from Arch Linux repository community/python-matplotlib.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy