The standard colormaps also all have reversed versions. They have the same names with _r tacked on to the end. (Documentation here.)

Answer from ptomato on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-reverse-a-colormap-using-matplotlib-in-python
How to reverse a Colormap using Matplotlib in Python? - GeeksforGeeks
July 23, 2025 - Now let's reverse the colormap and see how well it looks like. Example 2: Scatter Plot by reversing the colormap by using reversed() function. ... # importing the necessary libraries import matplotlib.pyplot as plt import numpy as np # creating ...
🌐
Delft Stack
delftstack.com › home › howto › matplotlib › reverse colormap python
How to Create Reverse Colormap in Python Matplotlib | Delft Stack
February 2, 2024 - We can reverse a colormap by adding _r at the end of the colormap’s name in Matplotlib. e.g. cmap='viridis_r' will simply reverse the viridis colormap.
🌐
Matplotlib
matplotlib.org › stable › users › explain › colors › colormaps.html
Choosing Colormaps in Matplotlib — Matplotlib 3.11.2 documentation
Do separately for each category # so each plot can be pretty. To make scatter markers change # color along plot: # https://stackoverflow.com/q/8202605/ if cmap_category == 'Sequential': # These colormaps all start at high lightness, but we want them # reversed to look nice in the plot, so reverse ...
🌐
Matplotlib
matplotlib.org › stable › users › explain › colors › colormap-manipulation.html
Creating Colormaps in Matplotlib — Matplotlib 3.11.2 documentation
colors = ["#ffffcc", "#a1dab4", "#41b6c4", "#2c7fb8", "#253494"] my_cmap = ListedColormap(colors, name="my_cmap") my_cmap_r = my_cmap.reversed() plot_examples([my_cmap, my_cmap_r])
🌐
Skytowner
skytowner.com › explore › inverting_color_maps_in_matplotlib
Inverting color maps in Matplotlib
To invert a color map in Matplotlib, attach the _r suffix to the color map, like so: ... Here, the key is that we used gray_r instead of gray, which reverses the color map.
🌐
Google Groups
groups.google.com › g › scitools-iris › c › biD6F6OG9Og
Reverse Brewer colour map...
Hope it helps someone else in future and saves them a few hours... Nick ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Or just put an '_r'at the end of any built-in matplotlib colormap name. Reverses ...
🌐
Narkive
matplotlib-users.narkive.com › CxHiK8is › how-to-reverse-the-colorbar-and-its-label-at-the-same-time
[Matplotlib-users] how to reverse the colorbar and its label at the same time?
all code in pylab mode. import numpy as np import matplotlib as mat a = np.arange(100).reshape(10,10) contourf(a,levels=np.arange(0,101,10)) colorbar() in the above figure, colorbar label shows 0 at the bottom and 100 at the top. Yet I want the 0 at the top and the 100 at the bottom, with the same sequence of colors in the colorbar. One way is to reverse the cmap, and then reverse the colorbar labels at a = np.arange(100).reshape(10,10) contourf(a,levels=np.arange(0,101,10),cmap=mat.cm.jet_r) cbar = colorbar() cbar.set_ticks(np.arange(0,101,10)) cbar.set_ticklabels(np.arange(100,-1,-10)) Chao, import numpy as np import matplotlib.pyplot as plt a = np.arange(100).reshape(10,10) fig, ax1 = plt.subplots() CS = ax1.contourf(a,levels=np.arange(0,101,10)) cbar = plt.colorbar(CS) cbar.ax.invert_yaxis() Does that produce the desired results?
Find elsewhere
🌐
GitHub
gist.github.com › stefanv › 4146612
Reverse colormap · GitHub
reverse_cmap.py · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
🌐
Matplotlib
matplotlib.org › 3.1.0 › _modules › matplotlib › cm.html
matplotlib.cm — Matplotlib 3.1.0 documentation
May 18, 2019 - if 'red' in spec: return colors.LinearSegmentedColormap(name, spec, lutsize) elif 'listed' in spec: return colors.ListedColormap(spec['listed'], name) else: return colors.LinearSegmentedColormap.from_list(name, spec, lutsize) LUTSIZE = mpl.rcParams['image.lut'] # Generate the reversed specifications (all at once, to avoid # modify-when-iterating). datad.update({cmapname + '_r': _reverse_cmap_spec(spec) for cmapname, spec in datad.items()}) # Precache the cmaps with ``lutsize = LUTSIZE``. # Also add the reversed ones added in the section above: for cmapname in datad: cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE) cmap_d.update(cmaps_listed) locals().update(cmap_d) # Continue with definitions ...
🌐
PyMorton
pymorton.wordpress.com › 2015 › 08 › 27 › reversing-a-matplotlib-colormap
Reversing a matplotlib colormap - PyMorton - WordPress.com
February 26, 2016 - Initially, I couldn’t find an easy way to use it since it isn’t in the current version (1.4.3). I found the underlying data list it in “_cm_listed.py” in the Matplotlib Github listed as “_viridis_data”and built the colormap from the data list: viridis_cm = LinearSegmentedColormap.from_list('viridis', cm_data) Here is the figure I was working on with the viridis colormap: Looking at the figure, what I really wanted was the reverse of the colormap.
🌐
Bomberbot
bomberbot.com › python › mastering-colormap-reversal-in-matplotlib-a-comprehensive-guide-for-python-enthusiasts
Mastering Colormap Reversal in Matplotlib: A Comprehensive Guide for Python Enthusiasts - Bomberbot
Sometimes, you might want to create a custom colormap and then reverse it. Here's how you can do that: import matplotlib.pyplot as plt import matplotlib.colors as mcolors import numpy as np # Create a custom colormap colors = ['#ff0000', '#00ff00', '#0000ff'] # Red, Green, Blue n_bins = 100 # Number of discretizations custom_cmap = mcolors.LinearSegmentedColormap.from_list('custom', colors, N=n_bins) # Create the reversed version custom_cmap_r = custom_cmap.reversed() # Create sample data x = np.linspace(0, 10, 100) y = np.tan(x) # Create the plot plt.figure(figsize=(12, 6)) plt.subplot(121) plt.scatter(x, y, c=y, cmap=custom_cmap) plt.colorbar() plt.title('Custom Colormap') plt.subplot(122) plt.scatter(x, y, c=y, cmap=custom_cmap_r) plt.colorbar() plt.title('Reversed Custom Colormap') plt.tight_layout() plt.show()
🌐
Matplotlib
discourse.matplotlib.org › development
Inverse colormap function? - Development - Matplotlib
February 26, 2020 - Is there an inverse colormap function? It looks like not, but I figured I’d ask. For example, if I make a colormap, I can send it a value and it’ll return the RGBA number corresponding to that value. Is there a way I ca…
🌐
HoloViews
holoviews.org › user_guide › Colormaps.html
Colormaps — HoloViews v1.23.2
provider: package offering the colormap (‘matplotlib’, ‘bokeh’, or ‘colorcet’) source: original source or creator of the colormaps (‘cet’, ‘colorbrewer’, ‘d3’, ‘bids’,’misc’) bg: base/background color expected for the map (‘light’,’dark’,’medium’,’any’) reverse: whether the colormap name includes _r indicating that it is a reverse of a base map (True, False) The hv.plotting.list_cmaps...
🌐
Python Pool
pythonpool.com › home › matplotlib › matplotlib cmap: sequential, diverging, cyclic, and qualitative
Matplotlib cmap: Sequential, Diverging, Cyclic, and Qualitative
July 13, 2026 - You can retrieve a colormap object with plt.get_cmap(). Add _r to many built-in colormap names to reverse them.
🌐
Python Examples
pythonexamples.org › python-matplotlib-color-map
Python Matplotlib - Understanding and Using Colormaps
import matplotlib.pyplot as plt import numpy as np # Data x = np.linspace(0, 10, 100) y = np.sin(x) z = y ** 2 # Create line plot with reversed colormap plt.scatter(x, y, c=z, cmap='coolwarm_r', s=50) # Add colorbar plt.colorbar(label='Intensity') # Add labels and title plt.xlabel('X-axis') plt.ylabel('Y-axis') plt.title('Scatter Plot with Reversed Colormap') # Show plot plt.show()