a Lisp interface to the PGPLOT plotting library


PGPLOT-CL is a CMUCL interface to the PGPLOT scientific plotting library.

PGPLOT is a two-dimensional plotting library written in Fortran, with a C interface library for linking with C programs. PGPLOT-CL uses the CMUCL FFI (foreign function interface) to link with the PGPLOT C library.

PGPLOT supports most types of 2d graphs, line-styles, point-styles, axis-labels, histograms, polygons, colors, etc. The output is publication-quality.

PGPLOT-CL supports a wide variety of plotting devices, including X11, PostScript, and GIF, as well as lots of other devices lost to the mists of time. PGPLOT-CL supports up to 8 simultaneously open graphics devices.

The latest PGPLOT-CL has been tested under CMUCL 18d.

Although the current interface supports the CMUCL implementation of lisp, the implementation-dependent parts are separate from the main body of the code, so the code should be portable to other Lisp implementations.

PGPLOT itself may not be freely redistributed, but it is free for non-commercial use. The PGPLOT site contains the exact terms of the PGPLOT license.

PGPLOT-CL is not an ongoing project; it is just something that was kludged together in the course of the author's work. Nevertheless, bug-fixes and improvements will be gratefully accepted.


PGPLOT-CL is distributed under the terms of the LGPL, a copy of which is included in the distribution in the LICENCE file. PGPLOT itself is licensed more restrictively, however.

The author of PGPLOT-CL requests that any modified version differing from the version on this web site (the `standard distribution') should have a different name than `PGPLOT-CL', and should clearly state that it is not the standard distribution. Also, the author requests that email contacts be provided in modified versions of PGPLOT-CL. This software is provided as is, with no guarantees of suitability, stability, functionality, etc.


You can obtain a tar.gz file of PGPLOT-CL here. It contains a README file with information on contacting the author, several lisp source files, and a LICENSE file.

You will also need to download PGPLOT from the PGPLOT web site. You will need C and Fortran compilers to compile the library.


The following function makes the GIF plot pictured on this page
(defun test-plot (&key (device :gif) (filename "test.gif"))
  (let* ((n 100) 
         (x (make-array n :element-type 'double-float))
         (y1 (make-array n :element-type 'double-float))
         (y2 (make-array n :element-type 'double-float))
         ;; open the pgplot device
         (p (pgplot:open-device device :filename filename)))
    ;; fill in arrays with x, sin(x) and cos(x)
    (loop for i from 0 to (1- n)
          do (progn
               (setf (aref x i) (* i (/ (* 1.0d0 n)) 2.0d0 pi))
               (setf (aref y1 i) (cos (aref x i)))
               (setf (aref y2 i) (sin (aref x i)))))
    (pgplot:set-window p 0 6.4 -1.1 1.1)
    ;; do first pane (bottom)
    (pgplot:set-current-pane p
                             1 1  ;; pane 1 of 1 x panes
                             1 2  ;; pane 1 of 2 y panes
                             :y-separation 0.1  ;; y space between panes
                             :left-pad 0.20     ;; x space on left
			     :top-pad 0.05      ;; y space on top
			     :right-pad 0.05    ;; x space on right
                             :bottom-pad 0.08)  ;; y space on bottom
    (pgplot:box p)
    (pgplot:xlabel p "\\ga")
    (pgplot:ylabel p "cos(\\ga)" :x-offset -0.03)
    (pgplot:connect p x y1)
    (pgplot:write-text p "Cos" 4.0 0.5 :character-height 1.3)
    ;; do second pane (top)
    (pgplot:set-current-pane p
                             1 1  ;; pane 1 of 1 x panes
                             2 2  ;; pane 2 of 2 y panes
                             :y-separation 0.1  ;; y space between panes
                             :left-pad 0.20     ;; x space on left
                             :top-pad 0.05      ;; y space on top
			     :right-pad 0.05    ;; x space on right
                             :bottom-pad 0.08)  ;; y space on bottom
    (pgplot:box p)
    (pgplot:ylabel p "sin(\\ga)" :x-offset -0.03)
    (pgplot:connect p x y2)
    (pgplot:write-text p "Sin" 4.0 0.5 :character-height 1.3)
    (pgplot:close-device p)))

sample plot

To Do:

PGPLOT-CL does not support the image (pixmap) plot type. It also does not support contour labels.
Last modified: Sat Jul 14 18:22:34 2001
Hosted by