BMI Students

Tuesday, March 01, 2005

Matplotlib: graphing in python

So, I hate Excel; it drives me insane. Especially for making graphs. Worse is when you need to take an Excel graph and import it into Illustrator or something real in order to shape it up for publication. (Oh God, you don't submit raw Excel grahics for publication, do you?) You get a bizarre barf of broken text, clipping masks and assorted horrors to deal with in Illustrator. I want a graphing package that can spit out something like SVG that Illustrator can read natively.

Also, there's lots of times I'd prefer to make graphs with a script (say I need need many similar graphs for a figure or an animation, or I want some graphing on a webserver). Scripting Excel is of course a disaster.

One option here is Gnuplot. Gnuplot is the standard free plotting tool, and there's even a python library to allow calling gnuplot from python. Plus gnuplot can save files as SVG or postscript, allowing you to edit them in illustrator, or by hand in the case of the XML-based SVG. Unfortunately, I find gnuplot's syntax perplexing and the python-gnuplot link to be a bit funky. Plus the figures aren't that pretty.

Enter Matplotlib. Matplotlib is a plotting libabry for python that has a vaguely matlab-styled interface. This is a boon if you're coming from matlab, and not too much of a detriment otherwise. You can make pretty fancy graphics (alpha channels and nice antialiasing, which are not present in gnuplot as far as I know), or you can save them to SVG for editing in Illustrator or whatever. It's rather advanced, and great for scripting graphic creation.

Check out the demo page to see what it can do. Installing on OS X isn't too bad, but there are a few hoops to jump through. Or you can use fink to install it.

2 Comments:

  • PyX for Python is another option. A friend of mine likes it a lot.

    By Blogger brian, at 8:36 AM  

  • by the way, you are a big snob

    By Blogger brian, at 10:41 AM  

Post a Comment

<< Home