![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzHymc-dmS1Db7VecyyEOe5StTRIdewqM_6bFXNyNxRSJXny4aP-E6BQE1l85yWTgIgQmaRr8rlh5ABBYheA2vTerJWqI-wzCaiPnBQetk9en_-6DLC6mnD0J606ygAvIe6s9cIdklSt62/s320/Screen+shot+2009-12-17+at+3.59.12+PM.png)
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).
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdZg5mUjygbcjsIWnPIoS4JmmOpnhhOrf6lNZ7HfithYRJrLlUjvD2SvPtAfr4qyEE_lDX0ss8jEMLQIOBxJQn1UBlzjoKFhzUAZJZeGl2gYJsBxh-qVHG22V0p6wMw2I73NVVL83bEV8o/s320/Screen+shot+2009-12-17+at+4.22.00+PM.png)