shaare.it

ValueError: Colormap is not recognized

ValueError: Colormap is not recognized

$ python plot.py
Traceback (most recent call last):
  ...
ValueError: Colormap 'super_cool_map' is not recognized

Why this happens

The colormap name you passed to cmap does not exist in the installed version of Matplotlib.

Fix

Check for typos or use a valid colormap name like 'viridis', 'plasma', 'inferno', 'magma', 'cividis', 'Greys', etc.

Wrong code

import matplotlib.pyplot as plt
import numpy as np

data = np.random.rand(10, 10)
plt.imshow(data, cmap='super_cool_map')

Fixed code

import matplotlib.pyplot as plt
import numpy as np

data = np.random.rand(10, 10)
plt.imshow(data, cmap='viridis')