Skip to content

VIS: plot method cannot handle new 'C0'-like colors (matplotlib 2.0) #15516

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
jorisvandenbossche opened this issue Feb 27, 2017 · 4 comments · Fixed by #15873
Closed

VIS: plot method cannot handle new 'C0'-like colors (matplotlib 2.0) #15516

jorisvandenbossche opened this issue Feb 27, 2017 · 4 comments · Fixed by #15873
Labels

Comments

@jorisvandenbossche
Copy link
Member

matplotlib 2.0 introduced a few 2-character color abbreviations: C0, C1, C2, ... to refer to the colors of the current color cycle
(very handy! this way you can refer to a color of the color cycle without hardcoding it, and use it as a shortcut for color='tab:blue' if you want the new blue instead of the ugly color='b')

But, it seems pandas cannot handle this at the moment, as it tries to interpret it as multiple colors:

df = pd.DataFrame(np.random.randn(10,3), columns=['a', 'b', 'c'])
df.plot(color='C0')

gives ValueError: 'C0' can be parsed as both single color and color cycle. Specify each color using a list like ['C0'] or ['C', '0']

I know the error message already gives the solution (using color=['C0']), but I think it would be nice to special case those to have to working by default.

@jorisvandenbossche jorisvandenbossche added this to the Next Major Release milestone Feb 27, 2017
@GuessWhoSamFoo
Copy link
Contributor

This one is pretty old, but I'd love to revive it. I'm not sure how tests will cover this change. Is it alright if I give it a try anyway?

@jreback
Copy link
Contributor

jreback commented Mar 28, 2017

sure!

try adding. test with the code as above (u will check this plot works)

TomAugspurger pushed a commit that referenced this issue Apr 12, 2017
* VIS: Allow 'C0'-like plotting for plotting colors

* Added case color='' and support for mpl < 2.0

* Updated prop_cycle references to be compatible with matplotlib 1.5 and 2.0

* Separated test; Used more consise regex
@jbrockmendel
Copy link
Member

@jorisvandenbossche we're now getting warnings about upper-case letters. Do we want to support upper-case specifically? If not, its an easy edit to get rid of the warnings in the CI logs.

@jorisvandenbossche
Copy link
Member Author

Answered in the other thread, but to have it here as well: yes we want to support those upper-case ones specifically. They are a specific color naming scheme of matplotlib.
I don't think they are what cause the warnings (although maybe how it is implemented to parse them causes warnings)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants