Plotting in Lisp, Part II

Ok, I’ve given this gnuplot thing a little more thought, and I’m pretty sure that the interface is going to need a little more complexity in order to wield any sort of power. Since I’d like to be able to eventually use a significant subset of gnuplot’s features, it will need to be extensible. Continuing with my object-oriented approach from before, but now with a little more abstraction. First, we’re just going to consider simple 2d plotting. Imagine that we have a simple data series composed of a list of lists (effectively a 2d matrix):

;; 2d matrix of data, in effect
(defparameter *data* '((0.0 6) (0.1 2) (0.2 8) ...))

I am thinking that it would be best to create a “data series” object that maintains it. The idea is that data series objects can deal with different representations in a regularized way:

;; create a 2d data series object
(defparameter *series* (make-series-2d *data* "Optional Data Series Name"))

Then we would create a plot object:

;; create a 2d plot object
(defparameter *plot* (make-plot-2d))

Then we might add the data series to the plot on the x and y1 axes:

;; add the data series to the plot
(plot-2d-add-series *plot* *series* [various series-options here?])

We might plot it straightaway to see what it looks like:

;; show our plot
(plot-2d-draw *plot* [specify terminal here?])

Perhaps it would be nice to do some tweaking of the appearance:

;; set options for axes
(plot-2d-xrange *plot* 0.0 1.0)
(plot-2d-yrange *plot* 0.0 100.0)
(plot-2d-xtics *plot* 0.1)
(plot-2d-ytics *plot* 10)

;; set options for series appearance
(plot-2d-series-style *plot* *series* :lines)
(plot-2d-series-color *plot* *series* :red)
(plot-2d-series-legend *plot* *series* "Foo Series")

;; set more plot options
(plot-2d-title *plot* "Foo Versus Bar")
(plot-2d-xlabel *plot* "Thing")
(plot-2d-ylabel *plot* "Other Thing")

;; set terminal
(plot-2d-output *plot* "foo.eps")
(plot-2d-term *plot* :post)
(plot-2d-draw *plot*)

Anyway, this is what I’m thinking. It won’t deviate much from the existing gnuplot labels for things, so as to minimize confusion.

I’ve continued this discussion here.

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a