🌐
Matplotlib
matplotlib.org › stable › users › explain › colors › colormaps.html
Choosing Colormaps in Matplotlib — Matplotlib 3.11.2 documentation
mpl.rcParams.update({'font.size': 12}) # Number of colormap per subplot for particular cmap categories _DSUBS = {'Perceptually Uniform Sequential': 5, 'Sequential': 6, 'Sequential (2)': 6, 'Diverging': 6, 'Cyclic': 3, 'Qualitative': 4, 'Miscellaneous': 6} # Spacing between the colormaps of a subplot _DC = {'Perceptually Uniform Sequential': 1.4, 'Sequential': 0.7, 'Sequential (2)': 1.4, 'Diverging': 1.4, 'Cyclic': 1.4, 'Qualitative': 1.4, 'Miscellaneous': 1.4} # Indices to step through colormap x = np.linspace(0.0, 1.0, 100) # Do plot for cmap_category, cmap_list in cmaps.items(): # Do subplots so that colormaps have enough space.
🌐
Purdue
docs.rcac.purdue.edu › workshops › matplotlib › colormaps
Colormaps - RCAC Documentation
MatPlotLib has a great writeup ... as what each colormap looks like in greyscale. Using colormaps is quite simple: add the cmap='CMAP_NAME' option to the plotting function you are using and MatPlotLib will handle the rest....
People also ask

What does cmap mean in Matplotlib?
cmap selects the colormap that maps normalized data values to colors in artists such as imshow, scatter, and contour plots.
🌐
pythonpool.com
pythonpool.com › home › matplotlib › matplotlib cmap: sequential, diverging, cyclic, and qualitative
Matplotlib cmap: Sequential, Diverging, Cyclic, and Qualitative
Which Matplotlib colormap should I use?
Use sequential for ordered magnitude, diverging for a meaningful midpoint, cyclic for wraparound values, and qualitative for unordered categories.
🌐
pythonpool.com
pythonpool.com › home › matplotlib › matplotlib cmap: sequential, diverging, cyclic, and qualitative
Matplotlib cmap: Sequential, Diverging, Cyclic, and Qualitative
What is the difference between cmap and norm?
cmap chooses the colors, while norm maps data values into the interval used by the colormap.
🌐
pythonpool.com
pythonpool.com › home › matplotlib › matplotlib cmap: sequential, diverging, cyclic, and qualitative
Matplotlib cmap: Sequential, Diverging, Cyclic, and Qualitative
🌐
Matplotlib
matplotlib.org › stable › api › _as_gen › matplotlib.pyplot.get_cmap.html
matplotlib.pyplot.get_cmap — Matplotlib 3.11.2 documentation
If a Colormap instance, it will be returned. Otherwise, the name of a colormap known to Matplotlib, which will be resampled by lut. The default, None, means rcParams["image.cmap"] (default: 'viridis').
🌐
Chrisholdgraf
chrisholdgraf.com › matplotlib › tutorials › colors › colormaps.html
Colormaps in Matplotlib — Matplotlib 2.0.0b1.post7580.dev0+ge487118 documentation
By these measures, BrBG and RdBu are good options. coolwarm is a good option, but it doesn’t span a wide range of values (see grayscale section below). cmaps['Diverging'] = [ 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']
🌐
GeeksforGeeks
geeksforgeeks.org › python › matplotlib-pyplot-set_cmap-in-python
Matplotlib.pyplot.set_cmap() in Python - GeeksforGeeks
July 12, 2025 - Matplotlib.pyplot.set_cmap() is a function in matplotlib that is used to set the default colormap for the current image or plot.
🌐
Matplotlib
matplotlib.org › stable › gallery › color › colormap_reference.html
Colormap reference — Matplotlib 3.11.2 documentation
import matplotlib.pyplot as plt import numpy as np cmaps = [('Perceptually Uniform Sequential', [ 'viridis', 'plasma', 'inferno', 'magma', 'cividis']), ('Sequential', [ 'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', 'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', 'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']), ('Sequential (2)', [ 'gray', 'bone', 'pink', 'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper']), ('Diverging', [ 'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismi
🌐
Python Pool
pythonpool.com › home › matplotlib › matplotlib cmap: sequential, diverging, cyclic, and qualitative
Matplotlib cmap: Sequential, Diverging, Cyclic, and Qualitative
July 13, 2026 - Quick answer: Choose a Matplotlib colormap by data meaning: sequential for ordered magnitude, diverging for a meaningful midpoint, cyclic for wraparound quantities, and qualitative for categories. Pair cmap with explicit normalization and a colorbar.
🌐
Medium
samjdedes.medium.com › exploring-matplotlibs-colormaps-65f216103277
Exploring Matplotlib's Colormaps - Sam Dedes - Medium
February 12, 2021 - def plot_cmap(labels, data, ax, chart_type='bar', cmap=None): """ Creates chart of given type and colormap. Must instantiate fig, ax outside of function. Parameters: labels (list): labels for each data point data (list): data points to be graphed *kwargs chart_type (string): name of matplotlib chart type cmap (string): name of matplotlib colormap to use in plot Returns: matplotlib figure of data with labels, colored according to specified cmap """ # scale data for compatibility with cmap den = max(data) - min(data) scaled_data = [(datum-min(data))/den for datum in data] # get colors corresponding to data colors = [] my_cmap = get_cmap(cmap) for decimal in scaled_data: colors.append(my_cmap(decimal)) fig.patch.set_facecolor('white') try: getattr(ax, chart_type)(labels, data, color=colors) except: getattr(ax, chart_type)(data, labels=labels, colors=colors) plt.title(cmap)
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › matplotlib-colors-colormap-class-in-python
Matplotlib Colormaps - GeeksforGeeks
December 23, 2024 - import matplotlib.pyplot as plt import numpy as np from matplotlib.colors import ListedColormap colors = ["blue", "green", "yellow"] cmap = ListedColormap(colors) data = np.random.randn(10, 10) plt.imshow(data, cmap=cmap) plt.colorbar() plt.show()
🌐
Medium
medium.com › @stacyfuende › colormaps-in-python-faecd8010f6c
Colormaps in Python. Here are some alternative color maps… | by Stacy M | Medium
September 6, 2025 - Here are some alternative color maps (cmaps) you can use in your maps to convey different visual styles or highlight specific features. These are built into Matplotlib, and you can specify them in the cmap parameter:
🌐
Matplotlib
matplotlib.org › stable › api › _as_gen › matplotlib.colors.Colormap.html
matplotlib.colors.Colormap — Matplotlib 3.11.2 documentation
Deprecated since version 3.11: Use cmap.with_extremes(bad=..., under=..., over=...) or Colormap(bad=..., under=..., over=...) instead.
🌐
Kanaries
docs.kanaries.net › topics › Matplotlib › examples-matplotlib-cmaps
Matplotlib Colormaps: Interactive Explorer and Complete Gallery – Kanaries
August 19, 2026 - The explorer below renders every colormap that ships with Matplotlib, grouped the way the official docs group them. Click a color bar to copy its cmap= argument.
🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › colors › create and customise palettes in matplotlib
Create and customise palettes in Matplotlib
1 week ago - from matplotlib.colors import ListedColormap # Define your custom color palette custom_colors = ['#264653', '#2a9d8f', '#e9c46a', '#f4a261', '#e76f51'] # Create a ListedColormap custom_cmap = ListedColormap(custom_colors) custom_cmap
🌐
GitHub
github.com › tlambert03 › cmap
GitHub - tlambert03/cmap: Scientific colormaps for python, with only numpy dependency · GitHub
April 30, 2023 - 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.
Author: tlambert03
🌐
Readthedocs
cmap-docs.readthedocs.io › en › stable
cmap
cmap is a colormap library for python, providing all of the colormaps in matplotlib, vispy, cmocean, (and more), with no dependencies beyond numpy.
Top answer
1 of 4
8

You want to give to the colormap instance an argument varying between 0 and 1, this requires a minimum of planning, e.g.,

x = np.linspace(0,355/113, 101)
p = plt.get_cmap('plasma')
n = 23
for i in range(n):
    plt.plot(x, np.sin(x-i/2/n), color=p(i/(n-1)))
2 of 4
4

One way to achieve your goal is to slice-up a colormap and then plot each line with one of the resulting colors. See the lines below that can be integrated in your code in appropriate places.

import numpy as np
import matplotlib.pyplot as plt

# 1. Choose your desired colormap
cmap = plt.get_cmap('plasma')

# 2. Segmenting the whole range (from 0 to 1) of the color map into multiple segments
slicedCM = cmap(np.linspace(0, 1, len(Subjects))) 

# 3. Color the i-th line with the i-th color, i.e. slicedCM[i]
plt.plot(f, Welch, c=slicedCM[Subjects.index(Subject)]) 

(The first two lines can be put in the beginning and you can replace the line plotting curves in your code with the third line of code suggested above.)

Alternatively, and perhaps a neater approach, is using the below lines inside your main loop through Subjects:

cmap = plt.get_cmap('inferno')
plt.plot(f, Welch, c=cmap(Subjects.index(Subject)/len(Subjects))) 

(I see in your question that you are changing Subject when you load the file again into Subject. Just use another variable name, say, data = np.loadtxt... and then f, Welch = signal.welch(data, ..... Keep the codes for plotting with different colors as suggested above and you won't have any problem.)

🌐
Readthedocs
cmap-docs.readthedocs.io › en › latest › colormaps
Colormaps - cmap
Colormaps are used in a variety of contexts, including image processing, data visualization, and scientific visualization. The cmap library provides a number of built-in colormaps, including all of the colormaps in matplotlib, cmocean, colorbrewer, colorcet, crameri, and more.
🌐
Seaborn
deeplearningnerds.com › matplotlib-color-maps
Matplotlib - Colormaps
December 15, 2023 - The cmap parameter is the Colormap. Here we can choose the name of a Colormap provided by Matplotlib.
🌐
GitHub
github.com › hhuangwx › cmaps
GitHub - hhuangwx/cmaps: user defined colormaps in matplotlib. · GitHub
import matplotlib.pyplot as plt import 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.WhiteBlueGreenYellowRed) plt.colorbar()