Missing marker when using style=...
· Issue #14563 · pandas-dev/pandas (original) (raw)
There is an issue with the markers in the legend when working with the built-in matplotlib plot-wrapper in pandas. The problem is also in earlier versions and the only workaround I found is using matplotlib directly.
A small, complete example of the issue
import pandas as pd import matplotlib.pyplot as plt
df = pd.DataFrame({'A': [1, 2, 3, 4, 5, 6], 'B': [2, 4, 1, 3, 2, 4], 'C': [3, 3, 2, 6, 4, 2], 'X': [1, 2, 3, 4, 5, 6]})
fig, ax = plt.subplots()
for kind in 'ABC': df.plot('X', kind, label=kind, ax=ax, style='.')
plt.show()
Expected Output
The markers in the legend are missing, except for the last label. It however works if I don't use style=...
, but the default line-plot, like in this example:
import pandas as pd import matplotlib.pyplot as plt
df = pd.DataFrame({'A': [1, 2, 3, 4, 5, 6], 'B': [2, 4, 1, 3, 2, 4], 'C': [3, 3, 2, 6, 4, 2], 'X': [1, 2, 3, 4, 5, 6]})
fig, ax = plt.subplots()
for kind in 'ABC': df.plot('X', kind, label=kind, ax=ax)
plt.show()
Output of pd.show_versions()
INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Darwin OS-release: 16.1.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8
pandas: 0.19.0
nose: None
pip: 8.1.2
setuptools: 25.2.0
Cython: 0.24.1
numpy: 1.11.2
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None