Skip to content

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

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions