Closed
Description
Bug report
Bug summary
Line2D objects added to a legend with linestyle='None' but with marker='.' (or any other marker, as far as I can tell) do not retain their marker when retrieved from the legend with
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
## create Line2D objects with ls = 'None and marker = '.' to show markers in the legend w.o. lines
lines = [Line2D([0],[0],ls='None',marker='.') for i in range(2)]
labels = [1,2] ## dummy labels
print([line.get_marker() for line in lines]) ## prints ['.' , '.']
legend = plt.gca().legend(lines,labels)
## read Line2D objects from legend
lines = legend.get_lines()
labels = [text.get_text() for text in legend.get_texts()] ## read labels from each line
print([line.get_marker() for line in lines]) ## prints ['' , '' ]
## plot it up to confirm that legend is blank
plt.figure()
plt.gca().legend(lines,labels)
Actual outcome
# If applicable, paste t
5D49
he console output here
['.', '.']
['', '']
Expected outcome
A legend that is identical to the top legend, with markers (equivalently console output:
['.', '.']
['.', '.'])
Matplotlib version
- Operating system: macOS Mojave 10.14.4
- Matplotlib version: 3.2.2
- Matplotlib backend (
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inline - Python version: Python 3.6.8
- Jupyter version (if applicable): 4.4.0
- Other libraries:
conda