Change color cycle to another Qualitative set

How do I switch to using one of the other colour sets like tab20 or Paired?

I don’t know if it’s the proper way, but what’ll work on the ListedColormaps (which is what the qualitative ones are) is:

from cycler import cycler
color_cycle = cycler(color=plt.get_cmap('Set1').colors)

fig, ax = plt.subplots()
ax.set_prop_cycle(color_cycle)
for i in range(10):
    ax.plot((i+1)*np.arange(1,10))

That changes the colormap, but not to Set1. It gives me something else entirely; not sure what.

This works, but my linter gives me an error:

plt.rcParams["axes.prop_cycle"] = plt.cycler("color", plt.cm.Set1.colors)

Then you should perhaps consider raising a bug with the linter?

@tacaswell said the following on gitter:

static code analysis may be failing because we do https://github.com/matplotlib/matplotlib/blob/f80d56e69ba2b8a583540c75f1bf8494738839cc/lib/matplotlib/cm.py#L115-L117