Every six months or so I do a project that requires drawing graphs from Python code. I usually use pygdchart because it's easy and I know it but it's awfully primitive and ugly. I've admired the output of matplotlib so I thought I'd give it a try.

The 2d rendering is slow. I wrote a quicky program to generate a trivial graph with 4 points then render that plot to an image 10 times in a row. Depending on the backend it can take almost a second to render a graph! Here's the milliseconds it takes to render a single plot using each of the various matplotlib backends:

GD: 440
Agg: 650
Cairo: 850

SVG: 60
PS: 90

There's also the no-op backend Template, 50ms. That's as fast as matplotlib is ever going to be. I'm disappointed by GD performance; it's not doing antialiasing or anything. Also surprised just how fast the SVG rendering is. I hope that's a viable publication mechanism some day; right now MSIE doesn't support it and Firefox misrenders it.

tech
  2006-08-10 21:57 Z