Skip to content

plotting in pandas is not picking the list of colors passed, it only gets the first value #16822

Closed
@eyadsibai

Description

@eyadsibai

Code Sample, a copy-pastable example if possible

>>> df = pd.DataFrame({"A": range(4), "color": ['red', 'blue', 'blue', 'red']})
>>> ax = df.plot.bar(y='A', color=df['color'])
>>> [p.get_facecolor() for p in ax.patches]
[(1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0),
 (1.0, 0.0, 0.0, 1.0)]

Problem description

It plots correctly but it does not pick the right color per bar. it only pick the color of the first value in the list.
it was working perfectly in pandas 0.19.2

Expected Output

the plot should contain a different color as the list is being passed. Similar to matplotlib behavior and the old pandas version

Output of pd.show_versions()

pandas: 0.20.2
pytest: None
pip: 9.0.1
setuptools: 36.0.1
Cython: None
numpy: 1.12.1
scipy: 0.19.1
xarray: None
IPython: 5.4.1
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: 2.7.1 (dt dec pq3 ext lo64)
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    RegressionFunctionality that used to work in a prior pandas versionVisualizationplotting

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions