Skip to content

ax.set_prop_cycle does not allow 'CN' colors #14221

@u55

Description

@u55

Hi matplotlib developers,
I was surprised to discover that the cycler validation does not allow colors specified with 'CN' syntax.

import numpy as np
import matplotlib.pyplot as plt
from cycler import cycler

fig, ax = plt.subplots()
ax.set_prop_cycle(cycler(color=['C1', 'C0'])) # raises ValueError
# ax.set_prop_cycle(cycler(color=['tab:orange', 'tab:blue'])) # works fine
ax.plot(np.arange(9))
ax.plot(-np.arange(9))
plt.show()

If matplotlib can differentiate between {'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'} colors and {'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'} colors (case insensitive) anywhere else that a color is specified, then it seems to me that the cycler should be able to handle this as well. Thanks.

Tested with matplotlib 3.0.3 and python 3.7.3 (Anaconda) on Windows 10.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions