This code should do something akin to what you require:
Edit using masked_array:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.colors as colors
import numpy.ma as ma
#See http://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#truncate the colourmap
n_colours = 4
new_cmap = truncate_colormap(cm.get_cmap('spectral_r'), 0, 0.4, n=n_colours)
#discretise the colourmap
bounds = np.linspace(0,n_colors,n_colours+1)
norm = colors.BoundaryNorm(bounds, new_cmap.N)
#build array one
array1 = np.random.rand(10,10)
#build array two
array2 = np.random.randint(0,5,100).reshape(10,10)
#mask the array
array2 = ma.masked_array(array2, array2==0)
#plot it
plt.pcolormesh(array1,cmap = plt.cm.binary)
plt.pcolormesh(array2,cmap = new_cmap, norm=norm)
cbar = plt.colorbar()
plt.show()
Here is the new output using a masked array: