Monday, October 17, 2005

Eighth SoCal Piggies Meeting

The SoCal Piggies had their eighth meeting at USC (Salvatori Computer Science Center) on October 13th at 7:00 PM. Seven Piggies attended -- Daniel Arbuckle, Diane Trout, Brian Leair, Titus Brown, Grig Gheorghiu, Mark Kohler and Howard Golden.

The first presenter was Brian Leair, who introduced [WWW] the Python Imaging Library, aka PIL. Brian talked about the main PIL modules such as Image and ImageDraw, and showed snippets of code that load and save images from files, create new images from scratch, use antialiasing, and in general manipulate images in various ways. PIL offers a dazzling array of options when it comes to image manipulation, and it knows how to deal with a [WWW] zillion file formats. Brian was especially appreciative of the text handling capabilities of PIL. He showed us how easily you can embed text and use TrueType fonts in your images. The presentation ended with a demo of an OpenGL application that Brian wrote that showed a zoomable and rotatable 3D graphic, with the text on the axis being rendered in TrueType fonts via PIL. Words do not do justice to the coolness of the app.

You can see Brian's presentation [WWW] online or you can download it as a [WWW] PowerPoint file. Brian also mentioned a Python Cookbook recipe that uses PIL for watermarking images: [WWW] http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879.

Diane Trout was next, and she presented an overview of [WWW] matplotlib, a 2D plotting library written in Python, with a high degree of matlab compatibility. Diane talked about the main plotting functions and the [WWW] various backends available in matplotlib, then ran several [WWW] sample programs distributed with matplotlib (subplots, scatter plots, spectograms, etc.). By default the graphs are plotted on a canvas that allows you to pan and zoom on the X and Y axis for any combination of the axes that are plotted -- very spectacular. Diane also showed us some code she wrote that uses matplotlib in conjuction with HTML image maps, so that when you can click on a data point in the plot and see its coordinates or display other information about it.

Some caveats that Diane mentioned regarding matplotlib:

  • The GTK backend can cause problems if you run matplotlib commands interactively from the Python shell (basically if you close the GTK canvas you can't go back to the shell, due to the GTK event loop)

  • matplotlib is under very active development, and things are not always backward compatible, so expect your code to break here and there when upgrading to a new version

You can see Diane's presentation [WWW] in PDF format.

On the same matplotlib theme, Grig handed out some printouts showing a little module he wrote called [WWW] sparkplot, which uses matplotlib to create sparklines. [WWW] Edward Tufte introduced sparklines in a [WWW] sample chapter of his upcoming book "Beautiful Evidence". In his words, sparklines are "small, high-resolution graphics embedded in a context of words, numbers, images. Sparklines are data-intense, design-simple, word-sized graphics." The sparkplot module allows you to create sparklines as PNG files that can then be seamlessly displayed within your text. For example, here is the Los Angeles Lakers' road to their NBA title lakers2002" in 2002.

As is always the case, we had lively discussions outside of the 'official' presentations, while munching on some pizza. We covered such various subjects as [WWW] TurboGears, how to unit test a testing module, whether the Python community is really less friendly than the Ruby community (as some luminaries such as Martin Fowlers are [WWW] prone to declare), [WWW] Guido's time machine, and many others. It was fun, so come join us next time!

Many thanks to Brian and Diane for presenting and to Daniel for hosting the meeting.

The next meeting will be at USC again, with the following agenda:

  • Python and Unicode (Daniel Arbuckle)

  • metakit overview (Howard Golden)