Skip to content

Default behavior of plot.bar changed to plot a different color for each bar #20585

Closed
@Deborah-Digges

Description

@Deborah-Digges

Code Sample, a copy-pastable example if possible

BEFORE

df_india.groupby('sector').id.count().sort_values().plot.bar();

would result in a bar plot with all bars having the same color

AFTER version 0.20

df_india.groupby('sector').id.count().sort_values().plot.bar(color='cornflowerblue');

I need to explicitly provide a color, else each bar is colored differently

Minimal reproducible code:

import pandas as pd
df = pd.DataFrame({'account-start': ['2017-02-03', '2017-03-03', '2017-01-01'],
                   'client': ['Alice Anders', 'Bob Baker', 'Charlie Chaplin'],
                   'balance': [-1432.32, 10.43, 30000.00],
                   'db-id': [1234, 2424, 251],
                   'proxy-id': [525, 1525, 2542],
                   'rank': [52, 525, 32],
                   })
df.client.value_counts().plot.bar()

Output:

download

Problem description

Why was the behavior of Series.plot.bar changed to plot bars with different color? Visually these colors add nothing to the plot as different colors should only be used when they correspond to differences of meaning in the data.

Why is the default behavior to provide an unnecessarily visually overwhelming graph? It took me some time to realize why my bars suddenly started acting strangely. Now, I pass color='cornflowerblue' to get all my bars the same pleasant hue.

Reference for visual appeal and the use of colors: http://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf

Would it be possible to revert to the pre-0.20 behavior?

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

INSTALLED VERSIONS

commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-5-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: C.UTF-8
LANG: C.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.2.1
pip: 9.0.1
setuptools: 38.5.2
Cython: 0.26.1
numpy: 1.14.2
scipy: 1.0.0
pyarrow: 0.8.0
xarray: 0.10.1
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2018.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: 0.4.0
matplotlib: 2.1.0
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.0
bs4: 4.6.0
html5lib: 0.9999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions