I've been exploring matplotlib. It's complex enough that I probably need to get a book. I decided to revisit the problem of producing heat maps. In the last couple of posts (here and here), I mentioned a couple of methods that might be used: (scatter, pcolormesh, and pcolor).
But, today I'm going to use matplotlib.patches.Rectangle. Rather than post the code (140 lines in two scripts), I made a zipped Archive that includes:
• a directory containing three data files
(counts, topo.colors, colors for the rownames)
• Helper.py and HeatMapper.py
• example.pdf
Above is a part of the figure the code draws The whole thing is up on Dropbox here.
The code to draw the boxes is:
It took significantly less time to write this than the Cocoa app that does the same thing, and I think it gains a lot in flexibility.
Here is an example in black and white. It uses the result from binCounts() as the color (i.e. gray).