masked_data = np.random.random((100, 100))
masked_data = np.ma.masked_where(masked_data < 0.9, masked_data)
fig, ax = plt.subplots()
ax.imshow(gray_data, cmap=cm.gray)
ax.imshow(masked_data, cmap=cm.jet, interpolation='none')
plt.show()
Setting Transparency Based on Pixel Values in Matplotlib