- [Function]
(
gnuplot
file {setting value}* {plot {setting value}*}+)
Creates a Gnuplot file containing (optional) global file settings followed by one or more plots with (optional) plot-specific settings. Each plot is a list or seq in one of the following formats:
(
(
c1 c2 ... cn)
...)
- A list of lists where each sublist defines the "columns" of a Gnuplot point record.
(
x1 y1 x2 y2 ... xn yn)
- A flat list of x y point data.
(
v1 v2 ... vn)
- A flat list of values to graph in left-to-right order along the x axis.
(
object1 object2 ... objectn)
- A flat list of CLOS objects whose slots are graphed according to the :points setting.
Of these formats, only the first (point record) format is directly supported by Gnuplot. The other (flat list) formats require an interpretation of their data. The special :points setting described below can be used to specify the format of plots globally or individually. The function will attempt to determine the format of any flat list plot without a :points specification.
Settings
In general, each setting is the keyword name of a Gnuplot
setting followed by its value. Settings that appear
before the first plot become (global) gnuplot set
command
directives, e.g :title "Hiho"
becomes set title
"HiHo"
in the gnuplot file. Settings that appear after a
plot are unique to that plot.
Setting values are interpreted in the following way:
- Numbers and strings are passed directly to gnuplot without any interpretation. This means that a string can pass a multi-word gnuplot clause including spaces and commas.
- Keywords are treated specially by some settings (see the :style setting) else they are converted to a lowercase string and printed to the file.
- Symbols are converted to lowercase strings and printed to the file.
- Lists are clause groupings or range specifications.
gnuplot
supports following non-Gnu settings:
- :view bool
- If true then the
gnuplot
program is automatically called with file after it has been written. The default value is true. - :points { int | :y | :xy | slot |
(
slot1 ...)
} - Identifies the point format in flat lists of data. An integer value groups that many values into each point record, e.g. 2 means that each pair of values becomes a point record in the gnuplot file. The values :y and :xy can be used in place of 1 and 2, respectively. Otherwise the value should be the slot name (symbol) or list of slot names to access in a flat list of CLOS objects.
- :comment string
- Optional comment string to appear as the first line of file.
gnuplot
alters the syntax of the following Gnu settings:
- :style {plotstyle}
- A keyword plotstyle is expanded to the proper command form '
set style data {plotstyle}
'. Valid plotting styles are:lines :points :linespoints :impulses :dots :steps :fsteps :histeps :errorbars :xerrorbars :yerrorbars :xyerrorbars :errorlines :xerrorlines :yerrorlines :boxes :filledboxes :filledcurves :boxederrorbars :boxxyerrorbars :financebars :candlesticks :vector
See Gnuplot plotting styles for more information.
- :[txy]range
(
low high)
- The value is a list of two values. These global axis settings can be applied to individual plots as well.
Examples:
Example 1. Plotting data sets
(gnuplot "test.plt" '( 0 0 50 .9 100 0) ) (gnuplot "test.plt" :title "My envelopes" '(0 0 25 .9 75 .9 100 0) :title "ramp" '(0 1 5 .5 10 .1 100 0) :title "expt" '(0 0 50 1 100 0) :title "updown") (gnuplot "test.plt" :title "Random numbers" :points :y :style :impulses (loop repeat 20 collect (random 1.0))) (gnuplot "test.plt" :title "Hi Ho!" :nokey #t '(0 0 25 .9 80 .5 100 0) :with :linespoints (loop for i to 100 by 10 collect i collect (random 1.0)) :with :points) (gnuplot "test.plt" :title "Random Midis" :points '(time keynum duration) :style :xerrorbars :yrange '(60 100) (loop repeat 20 for beg = 0 then (+ beg (random 1.0)) for dur = (pick .1 .2 .3) for key = (between 70 80) collect (new midi :time beg :keynum key :duration dur)))
Example 2. Process output to Gnuplot
(define (simp num ) (process repeat num output (new midi :time (now) :keynum (random 127) :duration .1) wait (between .1 1))) (io "algo.plt" :title "My very own process" :nokey #t :style :points :pointsize 2) (events (simp 20 ) "algo.plt")
Variables:
*gnuplot*
- The shell command (string) to start gnuplot. Defaults to
"gnuplot"
. *gnuplot-default-settings*
- A list of default
settings passed to Gnuplot. Defaults to
(:view #t :style :linespoints)
.
See also:
gnuplot-file
[Class]