-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
plotting in pandas is not picking the list of colors passed, it only gets the first value #16822
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
I left a comment on #14757 which seems to be the culprit. |
#14757 looks unrelated, that was for |
The problem seems to be in def _get_colors(self, num_colors=None, color_kwds='color'):
color = self.kwds.get('color')
if color is None:
return super()._get_colors(self, num_colors=num_colors, color_kwds=color_kwds)
else:
num_colors = len(self.data) # maybe? may not work for some cases
return _get_standard_colors(color=kwds.get('color'), num_colors=num_colors) will need tests and stuff too. |
@TomAugspurger This a regression bug that can crash matplotlib(see below). I think this might be a bigger deal than "next major release" If you give a color as an RGB or RGBA tuple the dataframe plot command only forwards the first number and this(a single float) isn't a valid color so matplotlib crashes and plots a blank(broken really) graph.
works fine on 0.19
|
@bcolsen certainly a patch is welcome. We have 1900 issues, how does one prioritize? |
The next minor release is tomorrow, so you may not have time to get a PR in.
… On Jul 6, 2017, at 05:08, Jeff Reback ***@***.***> wrote:
@TomAugspurger This a regression bug that can crash matplotlib(see below). I think this might be a bigger deal than "next major release"
@bcolsen certainly a patch is welcome. We have 1900 issues, how does one prioritize?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@jreback Sorry for the bug triage suggestion...I clearly have no idea what your release scheduled is like. I can't get a PR in by tomorrow, but will have a look at it. This is what i have so far. Initially this line, seems to be the problem:
pandas/pandas/plotting/_style.py Line 100 in 9e55af2
but this code is in plotting.py in 0.19 and it works fine. The difference is in 0.19
in 0.20
|
Any update? |
I have a work around for people being affected by this: Plot with color in an extra list:
also fixes bar:
|
I'm still facing this issue... |
I am still facing the same issue. Why is this closed? |
Is it possible this issue crawled its way back in? Im trying to use this on a bar plot and it only picks up the first color no matter what I do. Any ideas/suggestions? |
This problem still exists |
In case this helps anyone, I was having this issue with For example: No c = ['black', blue', 'green']
ax = df.plot.barh(color=c)
print([p.get_facecolor() for p in ax.patches])
# [(0.0, 0.0, 0.0, 1.0), (0.0, 0.0, 0.0, 1.0), (0.0, 0.0, 0.0, 1.0)] vs With c = ['red', blue', 'green']
# where A is a column name in your df
ax = df.plot.barh(y="A", color=c)
print([p.get_facecolor() for p in ax.patches]) |
Code Sample, a copy-pastable example if possible
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
The text was updated successfully, but these errors were encountered: