More Chaco

Posted by matt
on Friday, November 07

I’ve been doing a little bit more tweaking with chaco, learning how to use groups and containers. The docs are great, if a bit incomplete, so I ended up looking at various examples.

I’ve updated my simple AM demo so that it now shows the frequency content of the signal (calculated on the fly, using an FFT).

The running program looks like this:

AM Demo with FFT
Uploaded with plasq’s Skitch!

I’d still like to add zooming and area selections to the x-axis, and tidy the plots up a bit, but it’s looking good.

The code used to generate this coolness was:

Short and sweet.

Exploration with Chaco

Posted by matt
on Wednesday, November 05

This morning I was reading this tutorial on Chaco, a 2-D visualisation toolkit for Python (it’s part of the enthought python distribution), and I wanted a toy project to get a feel for it.

I decided to put together a very quick model of amplitude modulation, the kind of thing elec-eng students cover early in their degrees.

I came up with this:

AM Demo
Uploaded with plasq’s Skitch!

It’s very heavily based on the code in the tutorial above, but it works well, and it looks and feels pretty cool.

I find this kind of app very useful for helping me get a feel for how something works, and using something like chaco in this way makes it very easy to throw quick models together to play with.

My next challenge to to find something useful to do with it!

Here’s the code:

Aesthetics in Plotting and Visualisation

Posted by matt
on Tuesday, October 28

I’m fairly sure that aesthetics play a large part in how people view your work – ugly correct results are probably viewed as being worse than pretty, but wrong results. Aesthetics must play a fairly big role in how people perceive your work.

I’ve just finished generating a lot of quiver plots for my thesis. A quiver plot is a graph of vectors, illustrating a flow field. My results typically show an image with motion vectors overlaid, all plotted with Matlab, a piece of software which is very heavily used in academia in the UK (and probably all over the world).

Matlab quiver plots are ugly, and all of my plotting got me wondering how other system’s quiver plots look. In particular, I’ve started playing with numpy and scipy, so I decided to do a quick comparison between matlab, and matplotlib, the python close of matlab’s plotting tools. The results are very interesting.

I generated a quick example motion field, and plotted it with quiver. Then I took screenshots. I used the Gimp on my Linux box, for the matlab example) and Skitch on my MacBook for the python example.

First, here’s the matlab example. This was generated on linux using Matlab 2007a:

matlab_quiver
Uploaded with plasq’s Skitch!

Here’s the matplotlib python example, generated using the enthought python distribution. I used colour here because I could: matplotlib’s quiver supports it out of the box. Matlab’s doesn’t.

Figure 1
Uploaded with plasq’s Skitch!

I think the difference between the results is abundantly clear. Matplotlib’s arrows look great, they’re shapely and well scaled. Matlab’s look like jaggedy lines in comparison. However, I think the main difference is down to anti-aliasing. The matplotlib’s result looks better because they’re smoother and look far more modern the 90s throwback that is matlab’s interface (on linux and Mac at least – I can’t speak for Windows).

These results have pretty much convinced me to try my next project using Python and scipy instead of Matlab. Not only is it completely free (EPD is free for academic use, and matplotlib, scipy and numpy are just plan free), the aesthetic is there too. It’s almost like python’s elegant simplicity ideals spilled over into their plotting engines.