Skip to main content

Matplotlib Colormap

Matplotlib Colormap

This a small tutorial for making custom color map for matplotlib .

You can also check the documentary page here

One simple way to make  the colormap is using the available colours. 

Here is a simple example .  

import matplotlib.pyplot as plt
from matplotlib import colors
import numpy as np
zvals = np.random.rand(10, 10)
#cmap=colors.LinearSegmentedColormap.from_list("mycolor",['white', 'red','green','black'])
cmap=colors.LinearSegmentedColormap.from_list("mycolor",['white','black'])
img = plt.imshow(zvals, interpolation='nearest', origin='lower',cmap=cmap)

 

 

 

 

 

 

 

  

Comments