opening it up with Common Lisp
Book review: Darwinia
Summer reading: Spin
the Omnivoire's Delimma
the Golem's Eye
I just ran across Ryan Adam’s work on Plotting in Lisp (parts one, two and three) on Lemonodor. Coincidently enough, it turns out that I started working on something similar a few months ago. I called in clnuplot. Which has, I think, a nice ring to it.
From Ryan’s posts, I think we’re approaching the problem from a similar angle. Here are a few notes from two months ago:
I’ve been slowly learning bits and pieces of GNUplot and writing Lisp code to generate data and command files for it. Today (17 May 2005) I spent a bit of time consolidating what I have into something that might be slightly more generally useful.
You can use GNUPlot by writing data files and running plots from the GNUPlot command line or by writing data files and command files and running those or by writing command files that have the data inline. What I’ve done is written some classes and functions that let you manipulate plots in Lisp and then write out a command file that can executed in GNUPlot.
The basic model is one of plots and data-sets. A plot contains information for the entire information display; for example, the title, the axis labels and so forth. Each data set contains information about how to display a single group of data in some format; e.g., the data, the display style, the name of the data in the legend and so forth. A plot contains one or data sets.
For example, I have a command that first calls make-plot with not data: :
and then later uses the returned plot to build up a number of data-sets: :
The final plot object returned contains a whole bunch of data sets.
Make-plot currently supports :line, :points and :bar styles. Plots can have titles, a label on the x-axis and the y-axis and custom labels for the legend. Much of the rest of the functionality of GNUplot is missing but the framework is in place to add it pretty easily (I thinkÔ I’ll be adding stuff as I need it). Look in the parameters
This command writes the plot object to its file. Each plot object specifies a host, fullpath (directory) and filename. The host and directory default to
When you call write-plot it will return the pathname to which the file is written. The file can be executed in GNUPlot (either by piping it from the command line (note bene, I haven’t tried this yet myself) or by using the load command in GNUPlot). The plot commands and data will all be included in this single file.
I do most in Macintosh Common Lisp and use Alexander Repenning’s AppleScript support under OS X to call out to the shell — it seems creaky but works surprisingly well! Once I got the basics in place, I’ve not had much time to add the obvious features (or even to publicize my work until today’s goad came along (thank John)). In any case, I couldn’t find Ryan’s e-mail on his blog so if anyone can put us in touch, it would be great to move forward on this together.
Copyright -- Gary Warren King, 2004 - 2006