I try to create a Color Mesh plot using a map of xy-coordinates and colors in this way:
from matplotlib.colors import ListedColormap
import numpy as np
%pylab inline
colors = ListedColormap(['red', 'blue', 'yellow'])
xx,yy = np.meshgrid(np.arange(1, 6, 1), np.arange(1, 6, 1))
zz = np.array([[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[2,2,0,0,0],
[2,2,0,0,0]])
pyplot.pcolormesh(xx, yy, zz, cmap = colors)
It works ok when there is a list of three colors and I try to map xy-points into all of that colors (like in the code above):
But when there is a list of three colors, and I try to map points only into two of them, mapping goes wrong:
zz = np.array([[1,1,1,1,1],
[1,1,1,1,1],
[1,1,1,1,1],
[0,0,0,0,0],
[0,0,0,0,0]])
pyplot.pcolormesh(xx, yy, zz, cmap = colors)
It should map into colors 0 (red) and 1 (blue), but I get plot with 0 (red) and 2 (yellow) colors. Where is the mistake?