Closed
Description
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)
Expected outcome (Matplotlib 2.1.0)
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
.