Skip to content
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

Cannot use hex strings or named matplotlib colors with DataFrame.plot #10299

Closed
pbreach opened this issue Jun 6, 2015 · 1 comment · Fixed by #11293
Closed

Cannot use hex strings or named matplotlib colors with DataFrame.plot #10299

pbreach opened this issue Jun 6, 2015 · 1 comment · Fixed by #11293
Milestone

Comments

@pbreach
Copy link
Contributor

pbreach commented Jun 6, 2015

I was going to put this on SO but I think it might belong here instead:

I have a pandas DataFrame where I want to plot each column as a line with the same color. This might sound useless but I am showing groups of lines from certain selections of the DataFrame. The only problem is it appears that the DataFrame.plot method does not accept any matplotlib hex strings or named colors in the color kwarg.

A trivial example:

pd.DataFrame([range(10),range(10)]).plot(color='#008000')

gives a blank subplot with no errors, however,

pd.DataFrame([range(10),range(10)]).plot(color='g')

gives the expected result. To me this seems like a bug considering that color='g' works but not its hex string equivalent. The same issue occurs when trying to use a named matplotlib color like color='lightgray'. This does however work when using Series.plot or DataFrame.plot with one column or if a list of hex strings or named colors are given with length equal to the number of columns as in,

pd.DataFrame([range(10),range(10)]).plot(color=['#008000']*2)
@TomAugspurger TomAugspurger added the Visualization plotting label Jun 8, 2015
@TomAugspurger TomAugspurger added this to the 0.17.0 milestone Jun 8, 2015
@TomAugspurger
Copy link
Contributor

Looks like we parser color='bgr' color line 1 blue, line 2 green, line 3 red. It tries to do that here when it sees a list of characters, but '#' isn't a valid color.

I'd be open to a pull request to support this.

@jreback jreback modified the milestones: Next Major Release, 0.17.0 Aug 19, 2015
@jreback jreback modified the milestones: 0.17.1, Next Major Release Oct 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants