Skip to content
Super Duper Doopa Booka Lispy Gnuplot library
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Added note that cl-jupyter needs to be pulled from git repo Jan 12, 2016
roswell added roswell template Nov 16, 2016
src sorry, but "set view" syntax is complex to handle Jul 26, 2018
t x/yrange etc. are properly wrapped by [] Nov 18, 2016
.gitignore test local escape from with-plots Jul 8, 2016
.travis.yml remove alisp from the test (it froze on travis) Feb 4, 2016
README.org added roswell template Nov 16, 2016
eazy-gnuplot.asd issue #34 Jul 8, 2016
eazy-gnuplot.test.asd fix asd test Oct 3, 2015
plot.ros
sample.png modified readme Feb 4, 2016
test.dat test data Feb 4, 2016
test.ros

README.org

Eazy-Gnuplot https://travis-ci.org/guicho271828/eazy-gnuplot.svg

Lispy Gnuplot library

  • Structure-less – no CFFI, no CLOS, no STRUCTURE
  • Just print the data to the *standard-output* inside plot function

News

  • Supports a single datafile with multiple :using options. 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)` but also `: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).

Library Usage

Write 1 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:

https://raw.githubusercontent.com/guicho271828/eazy-gnuplot/master/sample.png

From the Command Line

Requirements: Install roswell.

PATH+=~/.roswell/bin/
ros install eazy-gnuplot
plot-init myplot.ros

How 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 .

Advanced Usage

Use 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.

Dependencies

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.

Author

  • Masataro Asai

Copyright

LLGPL

You can’t perform that action at this time.