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()

Answer from ImportanceOfBeingErnest on Stack Overflow
🌐
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 ·
🌐
Medium
medium.com › analytics-vidhya › python-matplotlib-36ad72381c0c
Python Matplotlib. Practical guideline for Business… | by ong kam siong | Analytics Vidhya | Medium
April 4, 2021 - Example: cm.tab20() consists of 20 colors provided by Tableau. By calling cm.tab20(0), we get color at index 0 of tab20 colormap which is darkblue.
🌐
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', ...
🌐
GitHub
github.com › matplotlib › matplotlib › blob › main › lib › matplotlib › _cm.py
matplotlib/lib/matplotlib/_cm.py at main · matplotlib/matplotlib
_tab20_data = ( (0.12156862745098039, 0.4666666666666667, 0.7058823529411765 ), # 1f77b4 · (0.6823529411764706, 0.7803921568627451, 0.9098039215686274 ), # aec7e8 · (1.0, 0.4980392156862745, 0.054901960784313725), # ff7f0e ·
Author: matplotlib
🌐
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']
Find elsewhere
🌐
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.
🌐
Python Graph Gallery
python-graph-gallery.com › categorical-color-palette
Use, customize and create categoric palettes in Matplotlib
import matplotlib.pyplot as plt · plt.get_cmap('Pastel1') plt.get_cmap('tab20') plt.get_cmap('Accent') Let's say you like the Accent palette and want to use to color the points in a scatter plot in matplotlib. Here's how you can do it: Load the necessary libraries ·
🌐
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
🌐
GitHub
github.com › djoshea › matlab-utils › blob › master › colormaps › matplotlib › tab20.m
matlab-utils/colormaps/matplotlib/tab20.m at master · djoshea/matlab-utils
Collection of miscellaneous shared utils for Matlab - matlab-utils/colormaps/matplotlib/tab20.m at master · djoshea/matlab-utils
Author: djoshea
🌐
GitHub
github.com › KrishnaswamyLab › scprep › blob › master › test › test_plot.py
scprep/test/test_plot.py at master · KrishnaswamyLab/scprep
np.array(matplotlib.cm.tab20c.colors)[ [0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18] ], ) np.testing.assert_array_equal( cmap.colors[15:], np.array(matplotlib.cm.tab20b.colors)[ [0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18] ], ) ·
Author: KrishnaswamyLab
🌐
Noga H. Rotman
r02b.github.io › seaborn_palettes
Seaborn Color Palettes and How to Use Them | Noga H. Rotman
November 8, 2022 - The matlab default palette we all know and love is called tab10, and is also the default palette for most seaborn functions. The seaborn variations are: deep, muted, pastel, bright, dark, and colorblind, while the matplotlib palettes are tab20, tab20b and tab20c.
🌐
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()

🌐
ResearchGate
researchgate.net › figure › Trend-topics-plot-obtained-with-the-matplotlib-tab20-color-palette-with-the-data_fig4_395994107
Trend topics plot obtained with the matplotlib tab20 color palette with... | Download Scientific Diagram
Download scientific diagram | Trend topics plot obtained with the matplotlib tab20 color palette with the data extracted from the software Bibliometrix for a minimum keyword frequency of 5. from publication: Trends in Using Microalgae as a Green Energy Source: Conventional, Machine Learning, ...