Matplotlib change colormap tab20 to have three colors

Matplotlib has some new and very handy colormaps (tab colormap). What I miss is a feature to generate a colormap like tab20b or tab20c but with three hue levels instead of four ?

This solution is a bit complicated, is there an easier one ?

skip = []
for i in range(0,len(cm.colors)//4+1):
# the colormap is called Vega in my Matplotlib version
cm ='Vega20c')
cm_skip = [cm.colors[i] for i in range(len(cm.colors)) if i not in skip]

for i, c in enumerate(cm_skip):
    x = np.linspace(0,1)
    y = (i+1)*x + i
    plt.plot(x, y, color=c, linewidth=4)

enter image description here

The colormap in Matplotlib: enter image description here

EDIT: A more generic approach has been provided in this SO post.


If by "easier" you mean shorter, you can directly evaluate the colormap on a numpy array.

import matplotlib.pyplot as plt
import numpy as np

colors = (4./3*np.arange(20*3/4)).astype(int) )
plt.scatter(np.arange(15),np.ones(15), c=colors, s=180)

enter image description here