How to view all colormaps available in matplotlib?
Here's some code that plots all available colormaps linked to their ID's
import matplotlib as mpl
import matplotlib.pyplot as plt
def plot_colorMaps(cmap):
fig, ax = plt.subplots(figsize=(4,0.4))
col_map = plt.get_cmap(cmap)
mpl.colorbar.ColorbarBase(ax, cmap=col_map, orientation = 'horizontal')
plt.show()
for cmap_id in plt.colormaps():
print(cmap_id)
plot_colorMaps(cmap_id)
The output looks like this
Accent
Accent_r
Blues
etc...
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