I've been working on Self-Organising Maps for timbre analysis, and I needed a good way to make an interactive 3D plot of the SOMs so that I could visually verify what was going on. ... Actually it took me a while trying out a few options, to get something decent in place. That's why I'm documenting it here.
- Of course Matlab has some good scientific 3D plotting, and I did a couple of preliminary visualisations using that. However, it's not open-source, it doesn't dovetail particularly nicely with SuperCollider (which is where my data is coming from), and it is a bit of a behemoth and I don't want it installed on my tiny Linux Eee PC.
- GNU Octave is pretty much an open-source clone of Matlab (it aims for language compatibility). It provides some basic matlabby plotting but lacks a lot of the advanced control, and also some features such as patch() are missing, which I needed.
- My number 1 hunch was that Python, with its popular scientific modules, would have some powerful 3D plotting right there. However, the standard matlab-like plotting module matplotlib doesn't have any 3D support. There's also something called mayavi which I think does OpenGL-based fancy 3D graphics, but I couldn't get it installed on my Mac so I couldn't test it out. I was really surprised not to be able to get very far with python and scientific 3D.
- Someone reminded me about scilab - silly of me to forget this one; it's a long-standing open-source science platform with visualisation tools, I bet it could have helped.
And here's the solution I finally settled on:
- gnuplot, plus the GNUPlot quark to be able to use it directly within SuperCollider. Gnuplot has a nice diversity of plotting styles available from its scripting language, and in the end it was surprisingly simple to script it to build what I wanted: 3D surface plots with little lines sticking out, representing the mapping from datapoints onto the SOM. It took me a while to understand that it's not oriented towards inline data: it gets much easier if you drop your data into a text file (CSV or suchlike) and work from that.
Here's an example of some test data which I piped straight from SuperCollider into gnuplot:
it works!