'How to create own cmap?

I tried the following code, but the matching name is used wrong. How to give a name to the created colour map, please?

import numpy as np
import matplotlib.pyplot as plt 

from matplotlib.colors import LinearSegmentedColormap

cMap = []
for value, colour in zip([28800, 29000, 29200, 29400, 29600, 29800, 30000],["darkblue", "mediumblue", "royalblue", "cornflowerblue", "dodgerblue", "skyblue", "paleturquoise"]):
    cMap.append((value, colour))

customColourMap = LinearSegmentedColormap.from_list("pri_c", cMap)

x=np.arange(9)
y=[9,2,8,4,5,7,6,8,7]

plt.scatter(x,y, c=y,cmap='pri_c')
plt.xlabel("X")
plt.ylabel("Y")
plt.title("Scatter Plot with Virdis colormap")
plt.colorbar()
plt.show()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source