The clgplot Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The clgplot Reference Manual

This is the clgplot Reference Manual, version 0.2, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 04:23:28 2022 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

* 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


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

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


Previous: , Up: Systems   [Contents][Index]

2.1 clgplot

Author

Satoshi Imai

License

MIT Licence

Description

A Gnuplot front-end for Common lisp

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
Source

clgplot.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

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


Previous: , Up: Modules   [Contents][Index]

3.1 clgplot/src

Parent

clgplot (system)

Location

src/

Component

clgplot.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

4 Files

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


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 clgplot.asd

Location

clgplot.asd

Systems

clgplot (system)

Packages

clgplot-asd


Previous: , Up: Lisp files   [Contents][Index]

4.1.2 clgplot/src/clgplot.lisp

Parent

src (module)

Location

src/clgplot.lisp

Packages

clgplot

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 clgplot-asd

Source

clgplot.asd

Use List

Previous: , Up: Packages   [Contents][Index]

5.2 clgplot

Source

clgplot.lisp (file)

Nickname

clgp

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

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


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Special variables

Special Variable: *default-terminal*
Package

clgplot

Source

clgplot.lisp (file)

Special Variable: *gnuplot-path*
Package

clgplot

Source

clgplot.lisp (file)

Special Variable: *tmp-dat-file*
Package

clgplot

Source

clgplot.lisp (file)

Special Variable: *tmp-gp-file*
Package

clgplot

Source

clgplot.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Macros

Macro: multiplot (&key LAYOUT OUTPUT OUTPUT-FORMAT) &body BODY
Package

clgplot

Source

clgplot.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 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 (file)

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 (file)

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 (file)

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 (file)

Function: seq START END &optional BY
Package

clgplot

Source

clgplot.lisp (file)

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 (file)

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 (file)

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 (file)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Macros

Macro: nlet TAG VAR-VALS &body BODY
Package

clgplot

Source

clgplot.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: appropriate-style-p STYLE
Package

clgplot

Source

clgplot.lisp (file)

Function: comma-separated-concatenate STRING-LIST
Package

clgplot

Source

clgplot.lisp (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

Function: last1 LST
Package

clgplot

Source

clgplot.lisp (file)

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 (file)

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 (file)

Function: run ()
Package

clgplot

Source

clgplot.lisp (file)

Function: search-min-max LIST &key MIN MAX
Package

clgplot

Source

clgplot.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L   M  
Index Entry  Section

C
clgplot.asd: The clgplot․asd file
clgplot/src: The clgplot/src module
clgplot/src/clgplot.lisp: The clgplot/src/clgplot․lisp file

F
File, Lisp, clgplot.asd: The clgplot․asd file
File, Lisp, clgplot/src/clgplot.lisp: The clgplot/src/clgplot․lisp file

L
Lisp File, clgplot.asd: The clgplot․asd file
Lisp File, clgplot/src/clgplot.lisp: The clgplot/src/clgplot․lisp file

M
Module, clgplot/src: The clgplot/src module

Jump to:   C   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

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

A
appropriate-style-p: Internal functions

C
comma-separated-concatenate: Internal functions

D
dump-gp-file: Internal functions
dump-gp-file-3d: Internal functions
dump-gp-file-append: Internal functions
dump-gp-stream: Internal functions

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

H
histogram-lem1: Internal functions

L
last1: Internal functions

M
Macro, multiplot: Exported macros
Macro, nlet: Internal macros
multiplot: Exported macros

N
nlet: Internal macros

P
plot: Exported functions
plot-for-multiplot: Internal functions
plot-histogram: Exported functions
plot-histogram-with-pdf: Exported functions
plots: Exported functions
plots-for-multiplot: Internal functions

R
run: Internal functions

S
search-min-max: Internal functions
seq: Exported functions
splot: Exported functions
splot-list: Exported functions
splot-matrix: Exported functions

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

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*default-terminal*: Exported special variables
*gnuplot-path*: Exported special variables
*tmp-dat-file*: Exported special variables
*tmp-gp-file*: Exported special variables

S
Special Variable, *default-terminal*: Exported special variables
Special Variable, *gnuplot-path*: Exported special variables
Special Variable, *tmp-dat-file*: Exported special variables
Special Variable, *tmp-gp-file*: Exported special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
clgplot: The clgplot system
clgplot: The clgplot package
clgplot-asd: The clgplot-asd package

P
Package, clgplot: The clgplot package
Package, clgplot-asd: The clgplot-asd package

S
System, clgplot: The clgplot system

Jump to:   C   P   S