The clgplot Reference Manual

This is the clgplot Reference Manual, version 0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:38:44 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 clgplot

A Gnuplot front-end for Common lisp

Author

Satoshi Imai

License

MIT Licence

Long Description

* clgplot
clgplot is a Gnuplot front-end on Common Lisp.

** Dependencies
Gnuplot (>4)

** Installation
#+BEGIN_SRC sh
cd ~/quicklisp/local-projects
git clone https://github.com/masatoi/clgplot.git
#+END_SRC

In case of using Roswell, simply
#+BEGIN_SRC sh
ros install masatoi/clgplot
#+END_SRC

#+BEGIN_SRC lisp
(ql:quickload :clgplot)
#+END_SRC

** Usage
clgplot generates a data file and a setting file of Gnuplot to tmp directory and execute Gnuplot with -persist option. Paths to these files or command can be changed as below.
#+BEGIN_SRC lisp
(defparameter clgp:*gnuplot-path* "gnuplot")
(defparameter clgp:*tmp-dat-file* "/tmp/clgplot-tmp.dat")
(defparameter clgp:*tmp-gp-file* "/tmp/clgplot-tmp.gp")
#+END_SRC

*** Plot of single function
#+BEGIN_SRC lisp
(defparameter *x-list* (loop for i from (- pi) to pi by 0.1 collect i))

(clgp:plot (mapcar #’sin *x-list*))
#+END_SRC

[[./docs/img/clgp01.png]]

Plots can be output to a file as follows.

#+begin_src lisp
(clgp:plot (mapcar #’sin *x-list*) :output "/path/to/file.png")
(clgp:plot (mapcar #’sin *x-list*) :output "/path/to/file.png" :output-format :png)
(clgp:plot (mapcar #’sin *x-list*) :output "/path/to/file.pdf" :output-format :pdf)
(clgp:plot (mapcar #’sin *x-list*) :output "/path/to/file.eps" :output-format :eps)
#+end_src

*** Plot of multiple functions with annotations
#+BEGIN_SRC lisp
(clgp:plots (list (mapcar #’sin *x-list*)
(mapcar #’cos *x-list*)
(mapcar #’tan *x-list*))
:x-seqs (list *x-list* *x-list* *x-list*)
:x-range (list (- pi) pi)
:y-range ’(-1 1)
:title-list ’("sin" "cos" "tan")
:x-label "x"
:y-label "f(x)")
#+END_SRC

[[./docs/img/clgp02.png]]

#+begin_src lisp
(let* ((rand-x-list (loop repeat 100 collect (- (random (* 2 pi)) pi)))
(rand-y-list (mapcar (lambda (x) (+ (sin x) (random-normal :sd 0.1d0))) rand-x-list)))
(clgp:plots (list (mapcar #’sin *x-list*)
rand-y-list)
:x-seqs (list *x-list* rand-x-list)
:style ’(line point)))
#+end_src

[[./docs/img/clgp02-2.png]]

*** 3D plot examples
#+BEGIN_SRC lisp
(clgp:splot (lambda (x y) (+ (sin x) (cos y)))
*x-list* ; x
*x-list* ; y
:view-point ’(20 45) :z-scale 1.5)
#+END_SRC

[[./docs/img/clgp03.png]]

#+BEGIN_SRC lisp
(clgp:splot (lambda (x y) (+ (sin x) (cos y)))
*x-list* ; x
*x-list* ; y
:map t)
#+END_SRC

[[./docs/img/clgp04.png]]

*** Plot matrix (2-dimensional array)

#+begin_src lisp
(defparameter mat
(make-array ’(20 20)
:initial-contents
(loop for i from (- pi) to (- pi 0.1) by (/ pi 10) collect
(loop for j from (- pi) to (- pi 0.1) by (/ pi 10) collect
(+ (sin i) (cos j))))))

(clgp:splot-matrix mat)
#+end_src

[[./docs/img/clgp05.png]]

*** Histogram

#+begin_src lisp
(defun random-normal (&key (mean 0d0) (sd 1d0))
(let ((alpha (random 1.0d0))
(beta (random 1.0d0)))
(+ (* sd
(sqrt (* -2 (log alpha)))
(sin (* 2 pi beta)))
mean)))

(clgp:plot-histogram (loop repeat 3000 collect (random-normal)) ; samples
30 ; number of bin
)
#+end_src

[[./docs/img/clgp06.png]]

*** Multiplot

#+begin_src lisp
(clgp:multiplot (:layout (2 2) :output "/tmp/multiplot.png" :output-format :png)
(clgp:plot (mapcar #’sin *x-list*) :style ’lines :key nil)
(clgp:plot (mapcar #’sin *x-list*) :style ’points :key nil)
(clgp:plot (mapcar #’sin *x-list*) :style ’impulses :key nil)
(clgp:plots (list (mapcar #’sin *x-list*)
(mapcar #’cos *x-list*)
(mapcar #’tan *x-list*))
:x-seqs (list *x-list* *x-list* *x-list*)
:x-range (list (- pi) pi)
:y-range ’(-1 1)
:key nil))
#+end_src

[[./docs/img/multiplot.png]]

** Author
Satoshi Imai (satoshi.imai@gmail.com)

** License
The MIT license

Version

0.2

Dependencies
  • uiop (system).
  • iterate (system).
Source

clgplot.asd.

Child Component

src (module).


3 Modules

Modules are listed depth-first from the system components tree.


3.1 clgplot/src

Source

clgplot.asd.

Parent Component

clgplot (system).

Child Component

clgplot.lisp (file).


4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


4.1 Lisp


4.1.1 clgplot/clgplot.asd

Source

clgplot.asd.

Parent Component

clgplot (system).

ASDF Systems

clgplot.

Packages

clgplot-asd.


4.1.2 clgplot/src/clgplot.lisp

Source

clgplot.asd.

Parent Component

src (module).

Packages

clgplot.

Public Interface
Internals

5 Packages

Packages are listed by definition order.


5.1 clgplot-asd

Source

clgplot.asd.

Use List
  • asdf/interface.
  • common-lisp.

5.2 clgplot

Source

clgplot.lisp.

Nickname

clgp

Use List
  • common-lisp.
  • iterate.
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


6.1 Public Interface


6.1.1 Special variables

Special Variable: *default-terminal*
Package

clgplot.

Source

clgplot.lisp.

Special Variable: *gnuplot-path*
Package

clgplot.

Source

clgplot.lisp.

Special Variable: *tmp-dat-file*
Package

clgplot.

Source

clgplot.lisp.

Special Variable: *tmp-gp-file*
Package

clgplot.

Source

clgplot.lisp.


6.1.2 Macros

Macro: multiplot ((&key layout output output-format) &body body)
Package

clgplot.

Source

clgplot.lisp.


6.1.3 Ordinary functions

Function: plot (y-seq &key x-seq title style x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key stream)
Package

clgplot.

Source

clgplot.lisp.

Function: plot-histogram (samples n-of-bin &key output x-range y-range x-logscale y-logscale)

Divide samples by the range width equally and count the number of samples appear in each bins.

Package

clgplot.

Source

clgplot.lisp.

Function: plot-histogram-with-pdf (samples n-of-bin pdf &key output x-range y-range x-logscale y-logscale)
Package

clgplot.

Source

clgplot.lisp.

Function: plots (y-seqs &key x-seqs title-list style x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key axis-list stream)
Package

clgplot.

Source

clgplot.lisp.

Function: seq (start end &optional by)
Package

clgplot.

Source

clgplot.lisp.

Function: splot (z-func x-seq y-seq &key title style x-label y-label z-label aspect-ratio output output-format x-logscale y-logscale z-logscale x-range y-range z-range x-range-reverse y-range-reverse z-range-reverse view-point magnification z-scale palette key map)
Package

clgplot.

Source

clgplot.lisp.

Function: splot-list (z-func x-list y-list &key title style x-label y-label z-label main aspect-ratio output output-format x-logscale y-logscale z-logscale x-range y-range z-range x-range-reverse y-range-reverse z-range-reverse view-point magnification z-scale palette key map)
Package

clgplot.

Source

clgplot.lisp.

Function: splot-matrix (matrix &key title style x-label y-label z-label output output-format x-range-reverse y-range-reverse z-range-reverse palette key)
Package

clgplot.

Source

clgplot.lisp.


6.2 Internals


6.2.1 Macros

Macro: nlet (tag var-vals &body body)
Package

clgplot.

Source

clgplot.lisp.


6.2.2 Ordinary functions

Function: appropriate-style-p (style)
Package

clgplot.

Source

clgplot.lisp.

Function: comma-separated-concatenate (string-list)
Package

clgplot.

Source

clgplot.lisp.

Function: dump-gp-file (plot-arg-format &key x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key)
Package

clgplot.

Source

clgplot.lisp.

Function: dump-gp-file-3d (plot-arg-format &key x-label y-label z-label main aspect-ratio output output-format x-logscale y-logscale z-logscale x-range y-range z-range x-range-reverse y-range-reverse z-range-reverse view-point magnification z-scale palette key map)
Package

clgplot.

Source

clgplot.lisp.

Function: dump-gp-file-append (plot-arg-format &key x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key)
Package

clgplot.

Source

clgplot.lisp.

Function: dump-gp-stream (stream plot-arg-format &key x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key)
Package

clgplot.

Source

clgplot.lisp.

Function: histogram-lem1 (x a b n)

Separate interval (a,b) equally to n bins, then return index of the bin which x belongs to.

Package

clgplot.

Source

clgplot.lisp.

Function: last1 (lst)
Package

clgplot.

Source

clgplot.lisp.

Function: plot-for-multiplot (plot-id y-seq &key x-seq title style x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key)
Package

clgplot.

Source

clgplot.lisp.

Function: plots-for-multiplot (plot-id y-seqs &key x-seqs title-list style x-label y-label main aspect-ratio output output-format x-logscale y-logscale x-range y-range x-range-reverse y-range-reverse key axis-list)
Package

clgplot.

Source

clgplot.lisp.

Function: run ()
Package

clgplot.

Source

clgplot.lisp.

Function: search-min-max (list &key min max)
Package

clgplot.

Source

clgplot.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   C   D   F   H   L   M   N   P   R   S  
Index Entry  Section

A
appropriate-style-p: Private ordinary functions

C
comma-separated-concatenate: Private ordinary functions

D
dump-gp-file: Private ordinary functions
dump-gp-file-3d: Private ordinary functions
dump-gp-file-append: Private ordinary functions
dump-gp-stream: Private ordinary functions

F
Function, appropriate-style-p: Private ordinary functions
Function, comma-separated-concatenate: Private ordinary functions
Function, dump-gp-file: Private ordinary functions
Function, dump-gp-file-3d: Private ordinary functions
Function, dump-gp-file-append: Private ordinary functions
Function, dump-gp-stream: Private ordinary functions
Function, histogram-lem1: Private ordinary functions
Function, last1: Private ordinary functions
Function, plot: Public ordinary functions
Function, plot-for-multiplot: Private ordinary functions
Function, plot-histogram: Public ordinary functions
Function, plot-histogram-with-pdf: Public ordinary functions
Function, plots: Public ordinary functions
Function, plots-for-multiplot: Private ordinary functions
Function, run: Private ordinary functions
Function, search-min-max: Private ordinary functions
Function, seq: Public ordinary functions
Function, splot: Public ordinary functions
Function, splot-list: Public ordinary functions
Function, splot-matrix: Public ordinary functions

H
histogram-lem1: Private ordinary functions

L
last1: Private ordinary functions

M
Macro, multiplot: Public macros
Macro, nlet: Private macros
multiplot: Public macros

N
nlet: Private macros

P
plot: Public ordinary functions
plot-for-multiplot: Private ordinary functions
plot-histogram: Public ordinary functions
plot-histogram-with-pdf: Public ordinary functions
plots: Public ordinary functions
plots-for-multiplot: Private ordinary functions

R
run: Private ordinary functions

S
search-min-max: Private ordinary functions
seq: Public ordinary functions
splot: Public ordinary functions
splot-list: Public ordinary functions
splot-matrix: Public ordinary functions