An extremely lightweight wrapper around a Gnuplot process.
The main entry point is the gnuplot
macro. For example, the Gnuplot program
set samples 400
set title "Example" font ",20"
plot [-10:10] real(sin(x)**besj0(x))
can be expressed as
(gnuplot
(:set :samples 400)
(:set :title "Example" :font ",20")
(:plot (fragment "[-10:10]") (fragment "real(sin(x)**besj0(x))")))
which renders as
For convenience, we provide a readtable fragment-syntax
which allows fragments to be delimited by curly brackets, so that {foo bar}
is read as (fragment "foo bar")
. Using this, we may rewrite the above example as
(named-readtables:in-readtable fragment-syntax)
(gnuplot
(:set :samples 400)
(:set :title "Example" :font ",20")
(:plot {[-10:10]} {real(sin(x)**besj0(x))}))
interactive-gnuplot
manages a Gnuplot process. Commands, specified as Lisp strings, may be executed via execute-command
.
Commands themselves may be built from gnuplot-fragment
objects, which may be concatenated to make a complete command. The generic translate-to-fragment
has methods which convert Lisp objects into fragments, and gnuplot-command-string
applies this to a list of objects. As an example:
INTERACTIVE-GNUPLOT> (translate-to-fragment :foo)
#S(GNUPLOT-FRAGMENT :STRING "foo")
INTERACTIVE-GNUPLOT> (gnuplot-command-string (list :plot (fragment "foo") :with "bar" 3))
"plot foo with \"bar\" 3"
The gnuplot
macro is just a friendly wrapper over this. The above example expands to
(PROGN
(EXECUTE-COMMAND (GNUPLOT-COMMAND-STRING (LIST :SET :SAMPLES 400)))
(EXECUTE-COMMAND
(GNUPLOT-COMMAND-STRING (LIST :SET :TITLE "Example" :FONT ",20")))
(EXECUTE-COMMAND
(GNUPLOT-COMMAND-STRING
(LIST :PLOT (FRAGMENT "[-10:10]") (FRAGMENT "real(sin(x)**besj0(x))")))))