-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Default behavior of plot.bar changed to plot a different color for each bar #20585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you have a reproducible example? This sounds like something that's been fixed, but it's hard to say without an example http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports |
Looks like a duplicate of #18394 |
Hi @TomAugspurger ! Thanks for replying. It's reproducible on version Minimal reproducible code:
Output: |
@TomAugspurger This isn't really a duplicate of the mentioned issue. The other one was caused as a result of this, but is not complaining of the same aesthetic appeal issue I refer to above. It is more complaining about functionality (logy=true) not working due to this new change. Hence, I believe it is a different issue |
I think they are related, but not the same issue. The issue I raise here is really one of visual design rather than broken functionality |
Sorry about that, wasn't reading closely enough. Thanks for the example. Could you edit your original post to include the example? Are you interested in submitting a pull request to fix this? |
no problem @TomAugspurger! I've updated the original post to include the example. I'd love to submit a PR for this as it's something that's been personally bothering me a lot :D However, I'm a bit new to the codebase so it may take a little while before I get the hang of stuff. I'll start digging around to see which portions of the code I need to touch for this. Is there a particular portion of the codebase you'd suggest I look at? |
Thanks! The plotting code is a bit tricky, but hopefully not too bad. I think the issue is lies around either
I notice that (Pdb) _get_standard_colors(num_colors=1)
['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', '#1f77b4'] So I'd say look through that and see if there's something fishy. Let me know if you get stuck, I haven't looked closely at it. If |
This definitely looks like a bug in
It is trying to increase the size of colors array in case number of items are less but does not handle case when size of colors array is larger than number of items asked. The side effect can be seen by calling (for any number less than 10 and result is 10 + number)
|
Code Sample, a copy-pastable example if possible
BEFORE
would result in a bar plot with all bars having the same color
AFTER version 0.20
I need to explicitly provide a color, else each bar is colored differently
Minimal reproducible code:
Output:
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
The text was updated successfully, but these errors were encountered: