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

Closed
jorisvandenbossche opened this Issue Feb 27, 2017 · 2 comments

Comments

Projects
None yet
3 participants

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 added this to the Next Major Release milestone Feb 27, 2017

Contributor

GuessWhoSamFoo commented Mar 28, 2017

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?

Contributor

jreback commented Mar 28, 2017

sure!

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

@TomAugspurger TomAugspurger added a commit that referenced this issue Apr 12, 2017

@GuessWhoSamFoo @TomAugspurger GuessWhoSamFoo + TomAugspurger VIS: Allow 'C0'-like plotting for plotting colors #15516 (#15873)
* 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
7b8a6b1

@linebp linebp added a commit to linebp/pandas that referenced this issue Apr 17, 2017

@GuessWhoSamFoo @linebp GuessWhoSamFoo + linebp VIS: Allow 'C0'-like plotting for plotting colors #15516 (#15873)
* 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
b305120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment