Skip to content

Adding names to the color in the new (Vega) default color cycle #7248

Closed
@anntzer

Description

@anntzer

The new default color cycle (Vega10, http://matplotlib.org/devdocs/users/dflt_style_changes.html#colors-color-cycles-and-color-maps) is pretty nice, but the colors are not named. Thus, the only way to refer to a specific color in that cycle is with the "Cn" syntax, which does not read as well.

For examples, consider something like

positive_values = ...
negative_values = ...
ax.plot(positive_values, c="C2")  # green-ish
ax.plot(negative_values, c="C3")  # red-ish

The intent is certainly less legible than

positive_values = ...
negative_values = ...
ax.plot(positive_values, c="g")
ax.plot(negative_values, c="r")

(using green for positive values and red for negative values is a not so rare convention).

(Of course, just using "g" and "r" or whatever CSS/XKCD color names doesn't really work either if you want to blend well with other figure elements that use the Vega10 palette.)

Thus, I'd suggest adding names to the colors of the Vega10/Vega20 palette, e.g. using the "vega:" prefix. Something like "blue", "orange", "green", "red", "purple", "brown", "pink", "gray", "yellow", "cyan" (all prefixed by "vega:" -- I don't think we can use "v:" due to the possible confusion with the triangle_down marker -- depends on the exact way the parser works...) looks close to what the colors are. The Vega20 palette (which adds lighter versions of all colors) can be supported as "vega:lightblue", etc. See https://github.com/vega/vega/wiki/Scales#scale-range-literals for the full palette.

Thoughts? The implementation itself is easy of course (just add the names to the named colors dict).

I think this should be milestoned to 2.0 or 2.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions