🌐
Matplotlib
matplotlib.org › stable › users › explain › colors › colormaps.html
Choosing Colormaps in Matplotlib — Matplotlib 3.11.2 documentation
Matplotlib has a number of built-in colormaps accessible via matplotlib.colormaps. There are also external libraries that have many extra colormaps, which can be viewed in the Third-party colormaps section of the Matplotlib documentation. Here we briefly discuss how to choose between the many ...
🌐
Colormaps
pratiman-91.github.io › colormaps
Home - Colormaps
import matplotlib.pyplot as plt import colormaps as cmaps import numpy as np x = y = np.arange(-3.0, 3.01, 0.05) X, Y = np.meshgrid(x, y) sigmax = sigmay = 1.0 mux = muy = sigmaxy=0.0 Xmu = X-mux Ymu = Y-muy rho = sigmaxy/(sigmax*sigmay) z = Xmu**2/sigmax**2 + Ymu**2/sigmay**2 - 2*rho*Xmu*Ymu/(sigmax*sigmay) denom = 2*np.pi*sigmax*sigmay*np.sqrt(1-rho**2) Z = np.exp(-z/(2*(1-rho**2))) / denom plt.pcolormesh(X,Y,Z,cmap=cmaps.cubehelix3_16_r) plt.colorbar()
🌐
GitHub
github.com › pyapp-kit › cmap
GitHub - pyapp-kit/cmap: Scientific colormaps for python, with only numpy dependency · GitHub
With cmap, you can use any of the colormaps from matplotlib, cmocean, colorbrewer, crameri, seaborn, and a host of other collections in your python code, without having to install matplotlib or any other dependencies beyond numpy.
🌐
Holoviz
colorcet.holoviz.org
Collection of perceptually accurate colormaps — colorcet v3.2.1
Colorcet is a collection of perceptually accurate 256-color colormaps for use with Python plotting programs like Bokeh, Matplotlib, HoloViews, and Datashader.
🌐
Purdue
docs.rcac.purdue.edu › workshops › matplotlib › colormaps
Colormaps - RCAC Documentation
Using colormaps is quite simple: add the cmap='CMAP_NAME' option to the plotting function you are using and MatPlotLib will handle the rest.
🌐
Readthedocs
cmap-docs.readthedocs.io › en › latest › colormaps
Colormaps - cmap
The cmap library provides a number of built-in colormaps, including all of the colormaps in matplotlib, cmocean, colorbrewer, colorcet, crameri, and more.
Find elsewhere
🌐
PYTHON CHARTS
python-charts.com › home › matplotlib colormaps
Matplotlib colormaps [Full List] | PYTHON CHARTS
July 29, 2026 - Matplotlib provides dozens of built-in colormaps: continuous or discrete color scales that you pass to the cmap argument whenever you map a numeric or categorical variable to color, for example in imshow, scatter, pcolormesh or a seaborn heatmap. This is different from the named colors page, which lists single, fixed colors instead of scales.
🌐
PyPI
pypi.org › project › cmap
cmap
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
Polyscope
polyscope.run › py › features › color_maps
Color Maps - Polyscope - Python
Load a new colormap from the image file filename, which will be assigned the name cmap_name.
🌐
MathWorks
mathworks.com › matlabcentral › fileexchange › 68239-pycolormap4matlab
PyColormap4Matlab - File Exchange - MATLAB Central
February 17, 2022 - Simple Matlab and python script that import colormaps from matplotlib into Matlab.
🌐
Medium
medium.com › data-science › beautiful-custom-colormaps-with-matplotlib-5bab3d1f0e72
Beautiful custom colormaps with Matplotlib | by Kerry Halupka | TDS Archive | Medium
July 28, 2020 - Let’s create a continuous colormap containing all of the colors above. We’ll be using the matplotlib.colors function called LinearSegmentedColormap. This function accepts a dictionary with a red, green and blue entries. Each entry should be a list of x, y0, y1 tuples, forming rows in a table.
🌐
Pythoncharts
pythoncharts.com › matplotlib › matplotlib-colors-colormaps
Python Charts - Colors and Color Maps in Matplotlib
Colormaps are preset lists/sequences/maps of colors that Matplotlib already has packaged up for us, ready to use.
Top answer
1 of 5
93

The error you are receiving is due to how you define jet. You are creating the base class Colormap with the name 'jet', but this is very different from getting the default definition of the 'jet' colormap. This base class should never be created directly, and only the subclasses should be instantiated.

What you've found with your example is a buggy behavior in Matplotlib. There should be a clearer error message generated when this code is run.

This is an updated version of your example:

import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
import numpy as np

# define some random data that emulates your indeded code:
NCURVES = 10
np.random.seed(101)
curves = [np.random.random(20) for i in range(NCURVES)]
values = range(NCURVES)

fig = plt.figure()
ax = fig.add_subplot(111)
# replace the next line 
#jet = colors.Colormap('jet')
# with
jet = cm = plt.get_cmap('jet') 
cNorm  = colors.Normalize(vmin=0, vmax=values[-1])
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)
print scalarMap.get_clim()

lines = []
for idx in range(len(curves)):
    line = curves[idx]
    colorVal = scalarMap.to_rgba(values[idx])
    colorText = (
        'color: (%4.2f,%4.2f,%4.2f)'%(colorVal[0],colorVal[1],colorVal[2])
        )
    retLine, = ax.plot(line,
                       color=colorVal,
                       label=colorText)
    lines.append(retLine)
#added this to get the legend to work
handles,labels = ax.get_legend_handles_labels()
ax.legend(handles, labels, loc='upper right')
ax.grid()
plt.show()

Resulting in:

Using a ScalarMappable is an improvement over the approach presented in my related answer: creating over 20 unique legend colors using matplotlib

2 of 5
89

I thought it would be beneficial to include what I consider to be a more simple method using numpy's linspace coupled with matplotlib's cm-type object. It's possible that the above solution is for an older version. I am using the python 3.4.3, matplotlib 1.4.3, and numpy 1.9.3., and my solution is as follows.

import matplotlib.pyplot as plt

from matplotlib import cm
from numpy import linspace

start = 0.0
stop = 1.0
number_of_lines= 1000
cm_subsection = linspace(start, stop, number_of_lines) 

colors = [ cm.jet(x) for x in cm_subsection ]

for i, color in enumerate(colors):
    plt.axhline(i, color=color)

plt.ylabel('Line Number')
plt.show()

This results in 1000 uniquely-colored lines that span the entire cm.jet colormap as pictured below. If you run this script you'll find that you can zoom in on the individual lines.

Now say I want my 1000 line colors to just span the greenish portion between lines 400 to 600. I simply change my start and stop values to 0.4 and 0.6 and this results in using only 20% of the cm.jet color map between 0.4 and 0.6.

So in a one line summary you can create a list of rgba colors from a matplotlib.cm colormap accordingly:

colors = [ cm.jet(x) for x in linspace(start, stop, number_of_lines) ]

In this case I use the commonly invoked map named jet but you can find the complete list of colormaps available in your matplotlib version by invoking:

>>> from matplotlib import cm
>>> dir(cm)
🌐
Bids
bids.github.io › colormap
matplotlib colormaps
Update: These colormaps have been merged into the development version of Matplotlib, all of them will be included in matplotlib 1.5, and "option D" (now called "viridis") will be the new default colormap in matplotlib 2.0. If you just want the colormaps themselves, they're available in a single file here under a CC0 "no rights reserved" license.
🌐
GitHub
github.com › pratiman-91 › colormaps
GitHub - pratiman-91/colormaps: Colormaps is a library of collection of colormaps or color palettes for Python. · GitHub
Colormaps is a library of collection of colormaps or color palettes for Python. - GitHub - pratiman-91/colormaps: Colormaps is a library of collection of colormaps or color palettes for Python.
🌐
Medium
medium.com › data-science › simple-steps-to-create-custom-colormaps-in-python-f21482778aa2
Simple steps to create custom colormaps in Python | by Guangyuan(Frank) Li | TDS Archive | Medium
October 26, 2021 - The logic of building a custom colormap in matplotlib is a little bit confusing at the first glance, it requires us to first create a cdict dictionary with the specification of red , green and blue channels’ dynamic changes.