I want to plot several RGB images on one set of axes with matplotlib. I initially tried using imshow for this, but it doesn't seem to handle two images on one set of axes with different extents (when I plot the second, it makes the first disappear). I think the answer here is to use pcolormesh, like in How to plot an irregular spaced RGB image using python and basemap?
However, this doesn't seem to work for me - the color coming from the mappable (i.e. the data array I pass to pcolormesh, and the cmap I specify) overrides the face color I specify. The edges of the grid do have the right color, but not the faces.
Does anyone know how to set the color of the faces directly? Ideally I'd use a pcolormesh that takes an n*m*3 array as an alternative to n*m, just like imshow...
A minimal example of how I'd like it to work: import numpy as np import matplotlib.pyplot as plt
#make some sample data
x, y = np.meshgrid(np.linspace(0,255,1),np.linspace(0,255,1))
r, g = np.meshgrid(np.linspace(0,255,100),np.linspace(0,255,120))
b=255-r
#this is now an RGB array, 100x100x3 that I want to display
rgb = np.array([r,g,b]).T
m = plt.pcolormesh(x, y, rgb/255.0, linewidth=0)
plt.show()
The problem is that the call to plt.pcolormesh fails, with
numRows, numCols = C.shape
ValueError: too many values to unpack
I guess this is because it wants a 2D array, not a 3D array with the last dimension being 3 long.