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.
(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)))