This is the clgplot Reference Manual, version 0.2, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 04:43:31 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
clgplot
A Gnuplot front-end for Common lisp
Satoshi Imai
MIT Licence
* 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
0.2
uiop
(system).
iterate
(system).
src
(module).
Modules are listed depth-first from the system components tree.
Files are sorted by type and then listed depth-first from the systems components trees.
clgplot/src/clgplot.lisp
src
(module).
*default-terminal*
(special variable).
*gnuplot-path*
(special variable).
*tmp-dat-file*
(special variable).
*tmp-gp-file*
(special variable).
multiplot
(macro).
plot
(function).
plot-histogram
(function).
plot-histogram-with-pdf
(function).
plots
(function).
seq
(function).
splot
(function).
splot-list
(function).
splot-matrix
(function).
appropriate-style-p
(function).
comma-separated-concatenate
(function).
dump-gp-file
(function).
dump-gp-file-3d
(function).
dump-gp-file-append
(function).
dump-gp-stream
(function).
histogram-lem1
(function).
last1
(function).
nlet
(macro).
plot-for-multiplot
(function).
plots-for-multiplot
(function).
run
(function).
search-min-max
(function).
Packages are listed by definition order.
clgplot
clgp
common-lisp
.
iterate
.
*default-terminal*
(special variable).
*gnuplot-path*
(special variable).
*tmp-dat-file*
(special variable).
*tmp-gp-file*
(special variable).
multiplot
(macro).
plot
(function).
plot-histogram
(function).
plot-histogram-with-pdf
(function).
plots
(function).
seq
(function).
splot
(function).
splot-list
(function).
splot-matrix
(function).
appropriate-style-p
(function).
comma-separated-concatenate
(function).
dump-gp-file
(function).
dump-gp-file-3d
(function).
dump-gp-file-append
(function).
dump-gp-stream
(function).
histogram-lem1
(function).
last1
(function).
nlet
(macro).
plot-for-multiplot
(function).
plots-for-multiplot
(function).
run
(function).
search-min-max
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Divide samples by the range width equally and count the number of samples appear in each bins.
Separate interval (a,b) equally to n bins, then return index of the bin which x belongs to.
Jump to: | A C D F H L M N P R S |
---|
Jump to: | A C D F H L M N P R S |
---|
Jump to: | *
S |
---|
Jump to: | *
S |
---|
Jump to: | C F M P S |
---|
Jump to: | C F M P S |
---|