I’m trying to create a 2d histogram that overlays three separate datasets. My idea is to color the datasets red, green, and blue, so that the density of the red data in a bin corresponds to the red value of that bin’s color, and likewise for blue and green.
There are examples of this, but so far as I can tell there’s no implementation of polychromatic plotting in matplotlib.
Getting to a grid of the form
[[ (r,g,b) , (r,g,b) ... (r,g,b) ] ,
[ (r,g,b) , (r,g,b) ... ] ,
.......
[ (r,g,b) , (r,g,b) ... (r,g,b) ]]
is no problem at all. The problem is that all the plotting functions I’ve found want to map single bin values onto a color scale, they don’t allow me to set the full color value of the bins.
Is there some primitive I should be looking for? Is there already a histogram to do this?
If your data is already in an RGB format (weighted between 0 and 1), then
imshowwill interpret a(M,N,3)-shaped array as an RGB array. Useinterpolation='nearest'to pixelise the output:If it is stored as a list of tuples, then a
np.array(...)will do the conversion.