A treemap viewer for python

As part of my current obsession with visualising test coverage for my huge app at work (I have a sneaky suspicion that other coders are not testing their code) I have been playing around with tree visualisation. My first port of call, graphviz, works ok for a small app but cant handle the huge app I’m interested in. eog was using all 1gig of my memory to try and render the svg file, which got quite boring. Then I remembered treemaps. They’re a great way of viewing trees where the nodes are considered to have a size.

I couldn’t find a decent viewer in python, so I thought I’d knock one up. It seems quick enough and does the job. I even used pylab to allow the use to zoom in on particular nodes to see whats going on in a busy part.

demo treemap

You can’t see the node labels, but they are displayed in the interactive map. I couldn’t think of a decent way of getting them into a node that could be really small.

It also became a nice guinea pig for testing the setuptools automate cheeseshop /pypi upload. Its really good, and worked without a hitch. You should now be able to do easy_install treemap!

No Trackbacks

You can leave a trackback using this URL: http://www.machine-envy.com/blog/2006/07/29/a-treemap-viewer-for-python/trackback/

5 Comments

  1. First thanks for creating this python implementation of treemaps!

    I couldn’t get the egg file to work – it worked just running __init__.py. I don’t know much about creating eggs, but think it should have code in a file named treemap or Treemap.

    I ended up renaming __init__.py to testtreemap.py in another directtory, then running easy_setup -f #egg=testreemap-1.0 testtreemap. The resulting egg file let me run the demo code from a separate file with the addition of “from testtreemap import Treemap”

    cheers

    Posted August 26, 2006 at 3:17 pm | Permalink
  2. Bram Stolk

    Hi,
    I could not get treemap-1.05 working.
    Like James, I added the ‘import treemap’ thing.
    I have python2.5 with numpy,scipy,matplotlib installed.
    Now I get:

    Exception in Tkinter callback
    Traceback (most recent call last):
    File “d:\python25\lib\lib-tk\Tkinter.py”, line 1403, in __call__
    return self.func(*args)
    File “D:\python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py”, lin
    e 212, in resize
    self.show()
    File “D:\python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py”, lin
    e 215, in draw
    FigureCanvasAgg.draw(self)
    File “D:\python25\Lib\site-packages\matplotlib\backends\backend_agg.py”, line
    279, in draw
    self.figure.draw(self.renderer)
    File “D:\python25\Lib\site-packages\matplotlib\figure.py”, line 772, in draw
    for a in self.axes: a.draw(renderer)
    File “D:\python25\Lib\site-packages\matplotlib\axes.py”, line 1601, in draw
    a.draw(renderer)
    File “D:\python25\Lib\site-packages\matplotlib\patches.py”, line 288, in draw
    r, g, b, a = colors.colorConverter.to_rgba(self._facecolor, self._alpha)
    File “D:\python25\Lib\site-packages\matplotlib\colors.py”, line 344, in to_rgb
    a
    raise ValueError(’to_rgba: Invalid rgba arg “%s”\n%s’ % (str(arg), exc))
    ValueError: to_rgba: Invalid rgba arg “60.4″
    to_rgb: Invalid rgb arg “60.4″
    cannot convert argument to rgb sequence

    Posted February 16, 2009 at 11:08 pm | Permalink
  3. Dugolo
    Posted August 10, 2009 at 6:11 pm | Permalink
  4. dugolo
    Posted August 10, 2009 at 6:12 pm | Permalink
  5. James Casbon

    That’s my code!

    Posted October 26, 2009 at 1:44 pm | Permalink

Post a Comment

Your email is never shared. Required fields are marked *

*
*