Skip to content

BUG: color list passed in as list/array/series of colors only picks up first color. #40605

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

Closed
RT-Tap opened this issue Mar 24, 2021 · 5 comments
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Needs Info Clarification about behavior needed to assess issue Visualization plotting

Comments

@RT-Tap
Copy link

RT-Tap commented Mar 24, 2021

So I found this issue was fixed in 2017 and 2019 respectively, however I think it's back. I spent half the day trying to figure out what I was doing wrong until I stumbled upon this thread/report: #16822
And it seems like the bug may have crawled its way back in? Sorry if I should not have opened a new bug report however you mentioned opening a new bug report for the 2019 reports of this bug so I figured I would report that it might be back as well.

  • [x ] I have checked that this issue has not already been reported.

  • [x ] I have confirmed this bug exists on the latest version of pandas.

  • [x ] (optional) I have confirmed this bug exists on the master branch of pandas.


Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Code Sample, a copy-pastable example

fullColors = list(itertools.repeat('#3FD21C',10)) + list(itertools.repeat('#ED5851',25))
df.plot(kind='bar', logy='sym', color=fullColors)
plt.show()

Problem description

So I have a dataframe with 1 data column and an index column, the dataframe has 50 values/rows in it and when i pass in a list of 50 colors I would expect those colors get matched up with each bar (or in my case half the bars are one color and half another) however only the first color passed in gets used to color all of the bars.

Expected Output

A bar graph with multiple colored bars rather than just 1 color

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f2c8480
python : 3.8.8.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 142 Stepping 11, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.2.3
numpy : 1.18.5
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 52.0.0.post20210125
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.21.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.3.4
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.1
sqlalchemy : 1.3.18
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
None

@RT-Tap RT-Tap added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 24, 2021
@jdouglas7122a
Copy link

Have you tried adding the colour list as an argument to the dataframe your using, then referencing that attribute of the df in the scatter? I had a similar problem with mpl.scatter, and that fixed it

@mroeschke mroeschke added Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 19, 2021
@MarcoGorelli
Copy link
Member

What's df? Please make your example reproducible

@MarcoGorelli MarcoGorelli added the Needs Info Clarification about behavior needed to assess issue label May 13, 2022
@RT-Tap
Copy link
Author

RT-Tap commented May 13, 2022

I posted this over a year ago so don't remember however i think i remember importing pandas as df because dataframe not sure where i got the word dataframe from or if pandas uses it. I havent used the library in some time but yea just import pandas as df ... i think, like i said it's been a while, not sure why it's coming back up unless someone else experienced this issue or maybe it's just finally getting some attention

EDIT: let me look though i might have this somewhere and if i find it or reproduce it i'll check back

@MarcoGorelli
Copy link
Member

MarcoGorelli commented May 13, 2022

For now, this looks fine, as the docs state:

colorstr, array-like, or dict, optional

The color for each of the DataFrame’s columns. Possible values are:

and your dataframe only has one column

@MarcoGorelli MarcoGorelli added the Closing Candidate May be closeable, needs more eyeballs label May 13, 2022
@MarcoGorelli
Copy link
Member

closing for now as I'm pretty sure this is behaving as documented, but can reopen if you paste a reproducible example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Closing Candidate May be closeable, needs more eyeballs Needs Info Clarification about behavior needed to assess issue Visualization plotting
Projects
None yet
Development

No branches or pull requests

4 participants