An intuitive CL interface to gnuplot.
Lispy Gnuplot library
- Structure-less -- no CFFI, no CLOS, no STRUCTURE
- Just print the data to the
- Supports a single datafile with multiple
:usingoptions. Plotting made more efficient. [Oct 2015]
- Supports for Multiplot environment partially available.
- When :terminal is missing, eazy-gnuplot tries to guess its terminal type from the given pathname.
- Growing the list of interfaces available as functions. Still, "unsupported commands" can be directly printed to the stream.
- Fitting function now available.
- Most arguments supports list notation. e.g. not only `:using '(1 2)` butalso `:errors`, `:via`, `:size`, `m?[xyzr]2?(range|tics)` ...
- PLOT function accepts strings (treated as functions) and pathnames (treated as datafile). func-plot and datafile-plot are deprecated (but still available).
with-plots and (at least) 1
gp-setup per output file.
gp-setup accepts and sets any attributes -- mighty
&allow-other-keys. no compatibility issue re: different gnuplot!.
For more examples, see the eazy-gnuplot cookbook !
;;; when :debug is non-nil, gnuplot code is copied to *trace-output* (with-plots (*standard-output* :debug t) (gp-setup :xlabel "x-label" ; strings : "\"x-label\"" :ylabel "y-label" :output #p"sample.png" ; pathnames : "\"sample.png\"" :terminal :png ; keyword/symbols: "terminal png" ;; list contents are recursively quoted, then joined by a space :key '(:bottom :right :font "Times New Roman, 6") :pointsize "0.4px" :yrange :|[0:1]| ;; currently, specifying these kinds of options requires to abuse ;; keywords and symbols. Another example: comma separated list, e.g., ;; :terminal '(:png :size |10cm,6cm|) ;; ;; 2/4/2016 Major options are now covered. ) ;; any unsupported commands are available by printing it to the stream (format t "~%unset key") ;; We are extending its expressivity. For example, as of 39d60d, there is gp-unset and gp-set. ;; An equivalent of above is (gp-unset :keys) . ;; The list is growing! ;; Functions can be protted with func-plot (plot "sin(x)" :title "super sin curve!") ;; Plot a lisp data directly (plot (lambda () (format t "~&0 0") (format t "~&1 1")) :using '(1 2) :title "1" :with '(:linespoint)) (plot (lambda () (format t "~&0 1") (format t "~&1 0")) :using '(1 2) :title "2" :with '(:lines)))
It results in the following png:
1.2From the Command Line
Requirements: Install roswell.
PATH+=~/.roswell/bin/ ros install eazy-gnuplot plot-init myplot.ros
1.3How it works
Above code This produces the following gnuplot code internally. It will then be fed into gnuplot interpreter.
set xlabel "x-label" set ylabel "y-label" set output "sample.png" set terminal png set key bottom right font "Times New Roman, 6" set pointsize "0.4px" plot sin(x) title "super sin curve!", '-' using 1:2 title "1" with linespoint, '-' using 1:2 title "2" with lines 0 0 1 1 end 0 1 1 0 end
When the script contains some error and gnuplot finishes with non-zero value, it signals UIOP:SUBPROCESS-ERROR .
2.1Use the GUI terminals e.g. WXT, QT
You can even try a wxt terminal or qt terminal and see the GUI interactively.
(eazy-gnuplot:with-plots (*standard-output* :debug t) (eazy-gnuplot:gp-setup :terminal '(:qt)) (eazy-gnuplot:plot (lambda () (format t "~&~A ~A" 1 2) (format t "~&~A ~A" 2 5) (format t "~&~A ~A" 3 4))) (format t "~&pause mouse button1;~%"))
However, these options may not be available on older versions of gnuplot. QT terminal is supported from gnuplot-4.6. WXT terminal has a known bug which leaves a zombie process until gnuplot-4.6.
This library is at least tested on implementation listed below:
- SBCL 1.2.1 on X86-64 Linux 3.13.0-39-generic (author's environment)
Also, it depends on the following libraries:
- ITERATE by
- Jonathan Amsterdam's iterator/gatherer/accumulator facility
- OPTIMA by Tomohiro Matsuyama
- Optimized Pattern Matching Library
- ALEXANDRIA by
- Alexandria is a collection of portable public domain utilities.
- Masataro Asai