plt.colormaps() returns a list of all registered colormaps. From the docs:

matplotlib.pyplot.colormaps()

Matplotlib provides a number of colormaps, and others can be added using register_cmap(). This function documents the built-in colormaps, and will also return a list of all registered colormaps if called.

The list this returns includes viridis, magma, inferno and plasma for me in 1.5.0

Answer from tmdavison on Stack Overflow
🌐
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.
🌐
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
🌐
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.
🌐
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.
🌐
Purdue
docs.rcac.purdue.edu › workshops › matplotlib › colormaps
Colormaps - RCAC Documentation
April 9, 2026 - 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....
Find elsewhere
🌐
Pythoncharts
pythoncharts.com › matplotlib › matplotlib-colors-colormaps
Python Charts - Colors and Color Maps in Matplotlib
Colormaps are accessible in many ways in Matplotlib, here are a few: # Using previous imports... # Via the most recent documentation, this first option seems to be recommended. viridis = mpl.colormaps['viridis'] viridis = plt.get_cmap('viridis') viridis = plt.cm.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']
🌐
Matplotlib
matplotlib.org › 2.0.2 › users › colormaps.html
Choosing Colormaps — Matplotlib 2.0.2 documentation
For the Diverging maps, we want to have monotonically increasing values up to a maximum, which should be close to , followed by monotonically decreasing values. We are looking for approximately equal minimum values at opposite ends of the colormap. By these measures, BrBG and RdBu are good options.
🌐
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 - Beautiful custom colormaps with Matplotlib Level up your chart game with custom colormaps to match your theme. If your Matplotlib chart needs a colormap and you’re not using an inbuilt map, chances …
🌐
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.
🌐
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:
🌐
DataCamp
datacamp.com › tutorial › matplotlib-colormaps
Matplotlib Colormaps: Customizing Your Color Schemes | DataCamp
November 9, 2024 - You can reverse any colormap in Matplotlib by appending the suffix _r in its name. # Set up the plot for the heatmap plt.figure(figsize=(12, 8)) # Create a custom normalization for the color range norm = mcolors.Normalize(vmin=16, vmax=40) # Plot the heatmap using imshow with the sequential colormap im = plt.imshow(monthly_temperature_table, cmap='YlOrRd_r', norm=norm, aspect='equal') # Add a color bar with a horizontal orientation cbar = plt.colorbar(im, orientation='horizontal', pad=0.1) cbar.set_label('Temperature (°C)', labelpad=10) # Add labels for the axes plt.xlabel('Day of the Month') plt.ylabel('Month') # Set y-ticks to display month names instead of numbers plt.yticks(ticks=np.arange(len(month_names)), labels=month_names) # Add a title plt.title('Temperature Heatmap (Sequential Colormap)') # Display the plot plt.show()
🌐
Reddit
reddit.com › r/cfd › colormaps explained courtesy of matplotlib. you spend a lot of time on your simulations, make sure you spend a little bit of time selecting the correct colormap for your figures.
r/CFD on Reddit: Colormaps explained courtesy of matplotlib. You spend a lot of time on your simulations, make sure you spend a little bit of time selecting the correct colormap for your figures.
October 30, 2020 - Whenever I see someone has not thought about the right color map for their results and has chosen the default option I instantly feel a negative bias towards their work, because if they were either too lazy or too lacking in understanding that they couldn't be bothered to choose something other than rainbow, what other things in their analyses received the same treatment.
🌐
Medium
samjdedes.medium.com › exploring-matplotlibs-colormaps-65f216103277
Exploring Matplotlib’s Colormaps
February 12, 2021 - Colorbars are a common feature ... this is cmap “afmhot” · While colormaps are essential to colorbars, they can also be useful as a visual aid to contrast values in all kinds of plots. Given a plot (bar, barh, pie, etc.), here are the tools to add a colormap and explore the different options. As always, ensure you have the essentials imported: import numpy as np import matplotlib.pyplot as ...
🌐
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 LinearSegmentedColormap colors = ["blue", "green", "yellow"] cmap = LinearSegmentedColormap.from_list("CustomCmap", colors) data = np.random.randn(10, 10) plt.imshow(data, cmap=cmap) plt.colorbar() plt.show()
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.)

🌐
Analytics Vidhya
analyticsvidhya.com › home › cmap in python: tutorials & examples | colormaps in matplotlib (updated 2026)
Cmap in Python: Tutorials & Examples | Colormaps in Matplotlib (Updated 2026)
January 2, 2026 - First, you can combine two Sequential colormaps in matplotlib colormap. Second, you can choose and combine your favorite color in RGB to create colormaps. We will give you a demo of combining two Sequential colormaps to create a new colormap.
🌐
StrataScratch
stratascratch.com › blog › how-to-customize-matplotlib-colors-for-better-plots
How to Customize Matplotlib Colors for Better Plots? - StrataScratch
February 24, 2025 - In the code below, we use mcolors.ListedColormap to define the cmap parameter and the list of colors in the custom colormap. Along the 'darkolivegreen' and 'snow' colors, we also add 'olivedrab', 'palegreen', and 'white' in between. The rest of the code is the same. import matplotlib.pyplot as plt import matplotlib.colors as mcolors # Define a ListedColormap with intermediate shades cmap = mcolors.ListedColormap(["darkolivegreen", "olivedrab", "palegreen", "white", "snow"]) # Plotting plt.figure(figsize=(10, 8)) contour = plt.contourf(x, y, z, 20, cmap=cmap) # Use 20 contour levels plt.colorbar(contour) plt.title('Geographical Elevation Levels of a Hiking Trail') plt.xlabel('Distance (km)') plt.ylabel('Distance (km)') plt.show()
🌐
Codedamn
codedamn.com › news › python
How to use matplotlib colormaps in Python?
March 9, 2024 - Matplotlib comes with a variety of built-in colormaps that you can use to enhance your plots. To apply a built-in colormap, simply specify the cmap parameter in your plotting function.