I'm trying to plot a 2D slice of a 3D figure with matplotlib PolyCollection, but I want to set a different color for each cell. Is there a way to easily create a colormap to accomplish this?
I have a set of vertices I'm plotting then using the array
argument to put an 2D array inside these vertices. I also have a 2D list that holds the RGB value for each cell. How can I generate a colormap from this 2D RGB list to pair with the PolyCollection?
For example:
import numpy
x = numpy.arange(4).reshape(2,2)
colors = [[(.2, .2, .3), (0, 0, 0)], [(.5, .5, .5), (.6, .3, .8)]]
I want the cell at (0, 0) to be (.2, .2, .3) and (0, 1) to be (0, 0, 0).
I'm guessing I need some combination of a Normalize instance and a ListedColormap.
Alternatively, is there a way to just pass an array of RGB values to
PolyCollection as the array
argument so that each 'value' is simply the color
of the cell?