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 = plt.cm.Vega20c( (4./3*np.arange(20*3/4)).astype(int) )
plt.scatter(np.arange(15),np.ones(15), c=colors, s=180)
plt.show()

Matplotlib
matplotlib.org › stable › users › explain › colors › colormaps.html
Choosing Colormaps in Matplotlib — Matplotlib 3.11.2 documentation
plot_color_gradients('Qualitative', ['Pastel1', 'Pastel2', 'Paired', 'Accent', 'okabe_ito', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c'])
Chengjun
chengjun.github.io › mybook › 19-visualization-matplotlib-colormap.html
Qualitative Colormaps in Matplotlib Visualization — 计算传播学
import matplotlib.pyplot as plt import numpy as np · NUM_COLORS = 20 cm = plt.get_cmap('gist_rainbow') fig = plt.figure() ax = fig.add_subplot(111) for i in range(NUM_COLORS): lines = ax.plot(np.arange(10)*(i+1)) lines[0].set_color(cm(i//3*3.0/NUM_COLORS)) lines[0].set_linewidth(i%3 + 1) #fig.savefig('moreColors.png') plt.show() 我们会更加推荐使用tab20这一colormap。 · NUM_COLORS = 20 cm = plt.get_cmap('tab20') fig = plt.figure() ax = fig.add_subplot(111) for i in range(NUM_COLORS): lines = ax.plot(np.arange(10)*(i+1)) lines[0].set_color(cm(i)) lines[0].set_linewidth(5) #fig.savefig('moreColors.png') plt.show() cm ·
Matplotlib
matplotlib.org › stable › gallery › color › colormap_reference.html
Colormap reference — Matplotlib 3.11.2 documentation
import matplotlib.pyplot as plt ... ('Qualitative', [ 'Pastel1', 'Pastel2', 'Paired', 'Accent', 'okabe_ito', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']), ('Miscellaneous', [ 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', ...
Mathworks
viewer.mathworks.com
tab20.m
We cannot provide a description for this page right now
Stack Overflow
stackoverflow.com › questions › 71198450 › matplotlibs-tab20-color-repeats-color-after-10
python - matplotlib's 'tab20' color repeats color after 10 - Stack Overflow
import glob from matplotlib import figure import matplotlib.pypot as plt import matplotlib.cm as mplcm import matplotlib.colors as colors import os import pandas as pd import matplotlib.pyplot as plt filelist = glob.glob('alkenes_testrg_cluster*.csv') filename = [((i.split('alkenes_testrg_')[1]).split('.')[0]).split('_')[0] for i in filelist] cm = plt.get_cmap('tab20',25) NUM_COLORS=25 sns.set(color_codes=True) sns.set(rc={"xtick.bottom" : True, "ytick.left" : True}) sns.set_style('darkgrid') #cNorm = colors.Normalize(vmin=0, vmax=NUM_COLORS-1) #scalarMap = mplcm.ScalarMappable(norm=cNorm, cma
Chrisholdgraf
chrisholdgraf.com › matplotlib › tutorials › colors › colormaps.html
Colormaps in Matplotlib — Matplotlib 2.0.0b1.post7580.dev0+ge487118 documentation
cmaps['Qualitative'] = ['Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']
Mathworks
jp.mathworks.com › matlabcentral › fileexchange › 62729-matplotlib-perceptually-uniform-colormaps
MatPlotLib "Perceptually Uniform" Colormaps - File Exchange - MATLAB Central
March 12, 2026 - From MatPlotLib 2 and 3: the default sequential colormap VIRIDIS (as well as INFERNO, MAGMA, and PLASMA), the default line colororder TAB10 (as well as TAB20, TAB20B, and TAB20C), the cyclic colormaps TWILIGHT and TWILIGHT_SHIFTED, the colorblind-friendly sequential colormap CIVIDIS.
W3Schools
w3schools.com › python › trypython.asp
W3Schools online PYTHON editor
The W3Schools online code editor allows you to edit code and view the result in your browser
Matplotlib
matplotlib.org › 2.0.2 › examples › color › colormaps_reference.html
color example code: colormaps_reference.py — Matplotlib 2.0.2 documentation
""" import numpy as np import ... 'seismic']), ('Qualitative', [ 'Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2', 'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b', 'tab20c']), ('Miscellaneous', [ 'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', 'gnuplot', ...
Top answer 1 of 2
5
You can create a ListedColormap from the colors of other colormaps.
E.g to get the darkorange color from the tab20c colormap, use plt.cm.tab20c(4) (as this is the 5th color in that map). Note that this works only for indexed colormaps - otherwise you need to use a value between 0 and 1.
From a list of thus obtained colors, you can create a new ListedColormap.
import matplotlib.pyplot as plt
import matplotlib.colors
import numpy as np
colors = [plt.cm.tab20(0),plt.cm.tab20(1),plt.cm.tab20c(4),
plt.cm.tab20c(5),plt.cm.tab20c(6),plt.cm.tab20c(7)]
cmap=matplotlib.colors.ListedColormap(colors)
x = np.arange(1,7)
plt.scatter(x,x,c=x, s=100, cmap=cmap, vmin=1, vmax=7)
plt.show()

Or, to get a nice colorbar as well,
import matplotlib.pyplot as plt
import matplotlib.colors
import numpy as np
colors = [plt.cm.tab20(0),plt.cm.tab20(1),plt.cm.tab20c(4),
plt.cm.tab20c(5),plt.cm.tab20c(6),plt.cm.tab20c(7)]
cmap=matplotlib.colors.ListedColormap(colors)
norm = matplotlib.colors.BoundaryNorm(np.arange(1,8)-0.5,len(colors))
x = np.arange(1,7)
sc = plt.scatter(x,x,c=x, s=100, cmap=cmap, norm=norm)
plt.colorbar(sc, ticks=x)
plt.show()

2 of 2
0
While not adding much to the answer above/below, it may be that one would want to add the entire set of colours from various different maps. There may be a better way to do this, but the following seems to work fine.
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
cols = []
for cn in ['tab20', 'tab20b', 'tab20c', 'viridis', 'plasma']:
cm = mpl.colormaps[cn].resampled(20)
cols += [cm(i) for i in range(20)]
myc=mpl.colors.ListedColormap(cols,'large')
x, y = np.meshgrid(np.arange(0,10), np.arange(0,10))
plt.gca().set_aspect('equal')
plt.scatter(x,y,c=y*10+x,marker='s', s=500, cmap=myc)
plt.show()
