This document is a companion for eazy-gnuplot users going through the 'excellent book by Lee Philips 'gnuplot Cookbook' from Packt Publishing. I highly recommend buying this book.
In this companion we demonstrate implementing the plots in the book using eazy-gnuplot
. Liberties have been taken plots may not follow exactly what is shown in the book (when they don't they follow the spirit).
This document is an iPython notebook from common-lisp-jupyter. Clone eazy-gnuplot or download this notebook at https://github.com/guicho271828/eazy-gnuplot/blob/master/docs/eazy-gnuplot-cookbook-companion.ipynb. Go to the downloaded directory and execute 'jupyter notebook' from a shell.
Edit: Updated the notebook for newer eazy-gnuplot and common-lisp-jupyter (a successor of cl-jupyter that is better maintained). I strongly recommend installation via Roswell (without it, installation is kind of manual). (Masataro Asai)
;png-from-file is used to display png files in cl-jupyter if not using cl-jupyter create a dummy function
(defun png-from-file (f) (jupyter:file f :display t))
PNG-FROM-FILE
;We need a directory called images to store our plots make sure it exists
(ensure-directories-exist "images/")
"images/"
NIL
(quicklisp-client:quickload '(:eazy-gnuplot :clml.statistics :clml.utility))
(use-package :eazy-gnuplot)
To load "eazy-gnuplot": Load 1 ASDF system: eazy-gnuplot ; Loading "eazy-gnuplot" [package lisp-namespace-asd] To load "clml.statistics": Load 1 ASDF system: clml.statistics ; Loading "clml.statistics" [package clml.statistics.rand-environment] To load "clml.utility": Load 1 ASDF system: clml.utility ; Loading "clml.utility" [package drakma-asd].............................. [package flexi-streams-system].................... [package chipz-system]...
(:EAZY-GNUPLOT :CLML.STATISTICS :CLML.UTILITY)
T
(defun function-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(plot "(sin(1/x) - cos(x))*erfc(x)"))
output)
(png-from-file (function-plot "images/function-plot.png"))
FUNCTION-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun seperate-y-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :y2tics '(-100 10) :ytics
:nomirror)
(plot "sin(1/x) axis x1y1,100*cos(x) axis x1y2"))
output)
(png-from-file (seperate-y-axis-plot "images/seperate-y-axis-plot.png"))
SEPERATE-Y-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun seperate-y-axis2-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :x2tics '(-20 2) :xtics
:nomirror :xrange '(-10 10) :x2range '(-20 10) :samples
100)
(plot "sin(1/x) axis x1y1")
(plot "100*cos(x-1) axis x2y2"))
output)
(png-from-file (seperate-y-axis2-plot "images/seperate-y-axis2-plot.png"))
SEPERATE-Y-AXIS2-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun scatter-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(plot
(lambda ()
(loop for p in (map 'list (lambda (x y) (list x y))
(clml.statistics:rand-n
(clml.statistics:chi-square-distribution 100) 300)
(clml.statistics:rand-n
(clml.statistics:chi-square-distribution 10) 300))
do (format s "~&~{~a~^ ~}" p)))
:with '(:points :pt 7)))
output)
(png-from-file (scatter-plot "images/scatter-plot.png"))
SCATTER-PLOT
(defun plotting-boxes-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :style '(:fill :pattern))
(plot "[-6:6] besj0(x) with boxes, sin(x) with boxes"))
output)
(png-from-file (plotting-boxes-plot "images/plotting-boxes-plot.png"))
PLOTTING-BOXES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun plotting-boxes-solid-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :style '(:fill :solid))
(plot "[-6:6] besj0(x) with boxes, sin(x) with boxes"))
output)
(png-from-file
(plotting-boxes-solid-plot "images/plotting-boxes-solid-plot.png"))
PLOTTING-BOXES-SOLID-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun plotting-circles-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(plot
(lambda ()
(loop for p in (map 'list (lambda (x y z)
(declare (ignorable z))
(list x y))
(clml.statistics:rand-n
(clml.statistics:chi-square-distribution 100) 300)
(clml.statistics:rand-n
(clml.statistics:chi-square-distribution 10) 300)
(clml.statistics:rand-n
(clml.statistics:chi-square-distribution 1) 300))
do (format s "~&~{~a~^ ~}" p)))
:with '(:circles)))
output)
(png-from-file (plotting-circles-plot "images/plotting-circles-plot.png"))
PLOTTING-CIRCLES-PLOT
(defun drawing-filled-curves-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :isosamples 1000)
(plot
(lambda ()
(loop for i from 0 upto 50
do (format s "~&~a ~a" i (sin i))))
:with '(:filledcurves :above :y1 = 0.07))
(plot
(lambda ()
(loop for i from 0 upto 50
do (format s "~&~a ~a" i (sin i))))
:with '(:lines)))
output)
(png-from-file
(drawing-filled-curves-plot "images/drawing-filled-curves-plot.png"))
DRAWING-FILLED-CURVES-PLOT
(defun drawing-blue-filled-curves (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :style '(fill pattern 5))
(plot
(lambda ()
(loop for i from 0 upto 50
do (format s "~&~a ~a" i (sin i))))
:lt '(rgb "blue") :with '(:filledcurves :above :y1 = 0.07))
(plot
(lambda ()
(loop for i from 0 upto 50
do (format s "~&~a ~a" i (sin i))))
:lt '(rgb "blue") :with '(:lines)))
output)
(png-from-file
(drawing-blue-filled-curves "images/drawing-blue-filled-curves.png"))
DRAWING-BLUE-FILLED-CURVES
This exercise requires Gnuplot 5
(defun filled-curves-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(:pngcairo) :output output :style
'(fill pattern 5))
(plot
(lambda ()
(loop for i from 0 upto 1 by 0.1
do (format s "~&~a ~a ~a" i i (sin i))))
:using '(1 2 3) :lw 3 :notitle ())
(plot
(lambda ()
(loop for i from 0 upto 1 by 0.1
do (format s "~&~a ~a ~a" i i (sin i))))
:using '(1 2) :lw 3 :notitle ())
(plot
(lambda ()
(loop for i from 0 upto 1 by 0.1
do (format s "~&~a ~a ~a" i i (sin i))))
:using '(1 3) :lw 3 :notitle () :with '(:filledcurves :above :y1 = 0.07)))
output)
(png-from-file (filled-curves-plot "images/filled-curves-plot.png"))
FILLED-CURVES-PLOT
;; does not work now; this google service is 404.
(defun finance-bars-plot (output)
(let ((s
(clml.utility.data:fetch
"http://www.google.com/finance/getprices?i=60&p=10d&f=d,o,h,l,c,v&df=cpct&q=ibm"
:stream t)))
(clml.utility.data:process-finance-header s)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :bars 2)
(plot
(lambda ()
(loop for row across (subseq
(clml.utility.csv:read-csv-stream s :type-spec
'(float float
float
float
float
float))
0 100)
do (format s "~&~{~a~^ ~}" (coerce row 'list))))
:using '(0 2 3 4 5) :with 'financebars)))
output)
;; (png-from-file (finance-bars-plot "images/finance-bars-plot.png"))
FINANCE-BARS-PLOT
(defun histogram-like-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(plot
(lambda ()
(loop for i from -2 upto 2 by 0.1
do (format s "~&~a ~a" i (- (* i i)))))
:with '(:histeps)))
output)
(png-from-file (histogram-like-plot "images/histogram-like-plot.png"))
HISTOGRAM-LIKE-PLOT
(defun histogram-stacked-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output :style
'(fill solid 1.0 border lt -1) :style '(data histograms) :style
'(histogram rowstacked))
(plot
(lambda ()
(loop for i from -2 upto 2 by 0.1
do (format s "~&~a ~a ~a ~a" i (- (* i i)) (* i i) i)))
:using (list "(-$2)") :using (list "(20*$2)") :notitle nil))
output)
(png-from-file (histogram-stacked-plot "images/histogram-stacked-plot.png"))
HISTOGRAM-STACKED-PLOT
(defun multiple-histograms-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title
"multiple histograms" :key '(invert reverse left outside) :key
'(autotitle columnheader) :style '(data histogram) :style
'(histogram rowstacked) :style '(fill solid border -1))
(flet ((data ()
(loop for r in '((8.01 1 5 1) (8.02 3 5 1) (8.03 4 4 1) (8.04 3 4 1)
(8.05 1 2 1))
do (format s "~&~{~^~a ~}" r))))
(plot #'data :using 2 :title "col0")
(plot #'data :using 2 :title "col1")
(plot #'data :using 3 :title "col2")
(plot #'data :using 4 :title "col3")))
output)
(png-from-file
(multiple-histograms-plot "images/multiple-histograms-plot.png"))
MULTIPLE-HISTOGRAMS-PLOT
(defun error-bars-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "error bars" :bars 3
:pointsize 3 :xrange '(8.0 8.06))
(flet ((data ()
(loop for r in '((8.01 1 0.2) (8.02 3 0.3) (8.03 4 0.4) (8.04 3 0.4) (8.05 1 0.1))
do (format s "~&~{~^~a ~}" r))))
(plot #'data :using '(1 |(-$2)| 3) :title "error" :with :errorbars)
(plot #'data :using '(1 |(-$2)| 3) :title "col0" :pt 7)))
output)
(png-from-file (error-bars-plot "images/error-bars-plot.png"))
ERROR-BARS-PLOT
(defun boxerror-bars-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "error bars" :style
'(fill pattern 2 border) :xrange '(8.0 8.06))
(plot
(lambda ()
(loop for r in '((8.01 1 0.2) (8.02 3 0.3) (8.03 4 0.4) (8.04 3 0.4)
(8.05 1 0.1))
do (format s "~&~{~^~a ~}" r)))
:using '(1 |($2)| 3) :with :boxerrorbars :title "boxers"))
output)
(png-from-file (boxerror-bars-plot "images/boxerror-bars-plot.png"))
BOXERROR-BARS-PLOT
(defun candlestick-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "candlestick"
:xrange '(0 5) :yrange '(0 25) :boxwidth '(0.2 absolute))
(flet ((data ()
(loop for r in '((1 5 7 10 15 24 0.3 "quick")
(2 6 8 11 16 23 0.4 "fox")
(3 5 7 11 17 22 0.5 "lazy")
(4 6 9 10 18 21 0.3 "dog"))
do (format s "~&~{~^~a ~}" r))))
(plot #'data :using '(1 3 2 6 5 |xticlabels(8)|) :with :candlesticks :title "quartiles")
(plot #'data :using '(1 4 4 4 4) :with :candlesticks :lt -1 :notitle ())))
output)
(png-from-file (candlestick-plot "images/candlestick-plot.png"))
CANDLESTICK-PLOT
(defun impluse-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "candlestick"
:xrange '(0 5))
(plot
(lambda ()
(loop for r in '((1 5 7 10 15 24 0.3 "quick")
(2 6 8 11 16 23 0.4 "fox")
(3 5 7 11 17 22 0.5 "lazy")
(4 6 9 10 18 21 0.3 "dog"))
do (format s "~&~{~^~a ~}" r)))
:using '(1 6 |xticlabels(8)|) :with :impulses :notitle ()))
output)
(png-from-file (impluse-plot "images/impluse-plot.png"))
IMPLUSE-PLOT
(defun stem-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "candlestick"
:xrange '(0 5) :yrange '(0 25))
(flet ((data ()
(loop for r in '((1 5 7 10 15 24 0.3 "quick")
(2 6 8 11 16 23 0.4 "fox")
(3 5 7 11 17 22 0.5 "lazy")
(4 6 9 10 18 21 0.3 "dog"))
do (format s "~&~{~^~a ~}" r))))
(plot #'data
:using '(1 6 |xticlabels(8)|) :with :impulses :lw 4 :title "counts")
(plot #'data
:using '(1 6) :with :points :pt 9 :notitle ())))
output)
(png-from-file (stem-plot "images/stem-plot.png"))
STEM-PLOT
(defun parametric-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "parametric"
:samples 1000 :parametric 'nil :trange '(-7 20))
(plot "sin(7*t), sin(111*t)" :notitle 'nil))
output)
(png-from-file (parametric-plot "images/parametric-plot.png"))
PARAMETRIC-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun parametric2-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "parametric"
:samples 1000 :parametric 'nil :trange '(-7 20))
(plot "sin(7*t), sin(111*t)" :notitle 'nil))
output)
(png-from-file (parametric2-plot "images/parametric2-plot.png"))
PARAMETRIC2-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun polar-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "polar" :xtics
:axis :xtics :nomirror :ytics :axis :ytics :nomirror :zeroaxis () :samples
500 :polar () :trange '(0 |12*pi|))
(gp :unset :border)
(gp :unset :raxis)
(plot "cos(7*t), sin(111*t)"))
output)
(png-from-file (polar-plot "images/polar-plot.png"))
POLAR-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun labeling-the-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title
"axis labels and lagends" :parametric 'nil :xlabel "time (sec.)"
:ylabel "amplitude" :y2label "error magnitude")
(flet ((data ()
(loop for x from -5 upto 5 by 0.1
do (format s "~&~a ~a ~a" x (sin x) (log x)))))
(plot #'data :using '(1 2 |(sgn($2))|) :with :filledcurves :notitle ())
(plot #'data :using '(1 2) :with :lines :title "square")
(plot #'data :using '(1 |(sgn($2))|) :with :lines :title "fourier")
(plot #'data :using '(1 |(abs(sgn($2)-$2))|) :with :lines :axis :x1y2 :title "error")))
output)
(png-from-file (labeling-the-axis-plot "images/labeling-the-axis-plot.png"))
LABELING-THE-AXIS-PLOT
If you have a postscript viewer like ghostscript you open the file at the path given by the output of `setting-label-size-plot. Other wise we have included a conversion of it to a png below
(defun setting-label-size-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(postscript landscape "courier, 18") :output output
:title "axis labels and lagends" :parametric 'nil :xlabel
"time (sec.)" :ylabel "amplitude" :y2label "error magnitude")
(flet ((data ()
(loop for x from -5 upto 5 by 0.1
do (format s "~&~a ~a ~a" x (sin x) (log x)))))
(plot #'data :using '(1 2 |(sgn($2))|) :with :filledcurves :notitle ())
(plot #'data :using '(1 2) :with :lines :title "square")
(plot #'data :using '(1 |(sgn($2))|) :with :lines :title "fourier")
(plot #'data :using '(1 |(abs(sgn($2)-$2))|) :with :lines :axis :x1y2 :title "error")))
output)
(png-from-file (setting-label-size-plot "images/setting-label-size-plot.ps"))
SETTING-LABEL-SIZE-PLOT
images/setting-label-size-plot.ps
(defun adding-a-legend-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title
"axis labels and lagends" :parametric 'nil :xlabel "time (sec.)"
:ylabel "amplitude" :y2label "error magnitude")
(flet ((data ()
(loop for x from -5 upto 5 by 0.1
do (format s "~&~a ~a ~a" x (sin x) (log x)))))
(plot #'data :using '(1 2 |(sgn($2))|) :with :filledcurves :notitle ())
(plot #'data :using '(1 2) :with :lines :title "square")
(plot #'data :using '(1 |(sgn($2))|) :with :lines :title "fourier")
(plot #'data :using '(1 |(abs(sgn($2)-$2))|) :with :lines :axis :x1y2 :title "error")))
output)
(png-from-file (adding-a-legend-plot "images/adding-a-legend-plot.png"))
ADDING-A-LEGEND-PLOT
(defun putting-a-box-around-a-legend-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title
"axis labels and lagends" :parametric 'nil :xlabel "time (sec.)"
:ylabel "amplitude" :y2label "error magnitude" :key
'(box lt -1 lw 2 opaque))
(flet ((data ()
(loop for x from -5 upto 5 by 0.1
do (format s "~&~a ~a ~a" x (sin x) (log x)))))
(plot #'data :using '(1 2 |(sgn($2))|) :with :filledcurves :notitle ())
(plot #'data :using '(1 2) :with :lines :title "square")
(plot #'data :using '(1 |(sgn($2))|) :with :lines :title "fourier")
(plot #'data :using '(1 |(abs(sgn($2)-$2))|) :with :lines :axis :x1y2 :title "error")))
output)
(png-from-file
(putting-a-box-around-a-legend-plot
"images/putting-a-box-around-a-legend-plot.png"))
PUTTING-A-BOX-AROUND-A-LEGEND-PLOT
(defun adding-a-label-with-arrow-plot (output)
(with-plots (s :debug t)
(gp-setup :output output :terminal '(:pngcairo) :title
"axis labels and lagends" :parametric 'nil :xlabel "time (sec.)"
:ylabel "amplitude" :y2label "error magnitude")
(gp :set :label "approximation error" :right :at '(-0.5 0.9) :offset '(-0.5 0) :front)
(gp :set :arrow :from :first '|-0.5 , 0.9| :to '|0 , 1| :lt 1 :lw 2 :front :size '(0.3 15))
(flet ((data ()
(loop for x from -5 upto 5 by 0.1
do (format s "~&~a ~a ~a" x (sin x) (log x)))))
(plot #'data :using '(1 2 |(sgn($2))|) :with :filledcurves :notitle ())
(plot #'data :using '(1 2) :with :lines :title "square")
(plot #'data :using '(1 |(sgn($2))|) :with :lines :title "fourier")
(plot #'data :using '(1 |(abs(sgn($2)-$2))|) :with :lines :axis :x1y2 :title "error")))
output)
(png-from-file
(adding-a-label-with-arrow-plot "images/adding-a-label-with-arrow-plot.png"))
ADDING-A-LABEL-WITH-ARROW-PLOT
" set terminal pngcairo set output \"images/adding-a-label-with-arrow-plot.png\" set title \"axis labels and lagends\" set parametric set xlabel \"time (sec.)\" set ylabel \"amplitude\" set y2label \"error magnitude\" set label \"approximation error\" right at -0.5,0.9 offset -0.5,0 front set arrow from first -0.5 , 0.9 to 0 , 1 lt 1 lw 2 front size 0.3,15 plot '-' using 1:2:(sgn($2)) with filledcurves notitle , '-' using 1:2 with lines title \"square\", '-' using 1:(sgn($2)) with lines title \"fourier\", '-' using 1:(abs(sgn($2)-$2)) with lines axis x1y2 title \"error\" -5 0.9589243 #C(1.609438 3.1415927) -4.9 0.9824526 #C(1.5892352 3.1415927) -4.8 0.9961646 #C(1.5686159 3.1415927) -4.7000003 0.9999233 #C(1.5475626 3.1415927) -4.6000004 0.993691 #C(1.5260564 3.1415927) -4.5000005 0.97753024 #C(1.5040776 3.1415927) -4.4000006 0.9516022 #C(1.4816047 3.1415927) -4.3000007 0.9161662 #C(1.4586152 3.1415927) -4.200001 0.87157613 #C(1.4350847 3.1415927) -4.100001 0.8182776 #C(1.4109871 3.1415927) -4.000001 0.7568031 #C(1.3862946 3.1415927) -3.900001 0.6877669 #C(1.3609768 3.1415927) -3.8000011 0.6118588 #C(1.3350013 3.1415927) -3.7000012 0.5298372 #C(1.3083332 3.1415927) -3.6000013 0.44252163 #C(1.2809342 3.1415927) -3.5000014 0.35078457 #C(1.2527634 3.1415927) -3.4000015 0.25554258 #C(1.2237759 3.1415927) -3.3000016 0.1577473 #C(1.193923 3.1415927) -3.2000017 0.058375858 #C(1.1631514 3.1415927) -3.1000018 -0.04157885 #C(1.1314027 3.1415927) -3.000002 -0.14111812 #C(1.0986129 3.1415927) -2.900002 -0.23924738 #C(1.0647115 3.1415927) -2.800002 -0.33498618 #C(1.0296202 3.1415927) -2.7000022 -0.4273779 #C(0.9932526 3.1415927) -2.6000023 -0.5154994 #C(0.95551234 3.1415927) -2.5000024 -0.5984702 #C(0.9162917 3.1415927) -2.4000025 -0.67546135 #C(0.87546974 3.1415927) -2.3000026 -0.7457035 #C(0.83291024 3.1415927) -2.2000027 -0.8084948 #C(0.7884586 3.1415927) -2.1000028 -0.863208 #C(0.74193865 3.1415927) -2.0000029 -0.9092962 #C(0.6931486 3.1415927) -1.9000028 -0.9462992 #C(0.64185536 3.1415927) -1.8000028 -0.973847 #C(0.5877882 3.1415927) -1.7000028 -0.99166447 #C(0.5306299 3.1415927) -1.6000028 -0.9995735 #C(0.47000536 3.1415927) -1.5000027 -0.9974952 #C(0.40546694 3.1415927) -1.4000027 -0.9854502 #C(0.33647418 3.1415927) -1.3000027 -0.9635589 #C(0.26236632 3.1415927) -1.2000027 -0.93204004 #C(0.18232378 3.1415927) -1.1000026 -0.8912086 #C(0.09531259 3.1415927) -1.0000026 -0.8414724 #C(2.622601e-6 3.1415927) -0.9000026 -0.78332853 #C(-0.105357625 3.1415927) -0.8000026 -0.7173579 #C(-0.22314033 3.1415927) -0.70000255 -0.64421964 #C(-0.3566713 3.1415927) -0.6000025 -0.5646446 #C(-0.5108214 3.1415927) -0.5000025 -0.47942773 #C(-0.6931422 3.1415927) -0.4000025 -0.38942066 #C(-0.91628444 3.1415927) -0.30000252 -0.2955226 #C(-1.2039645 3.1415927) -0.20000252 -0.1986718 #C(-1.6094253 3.1415927) -0.10000252 -0.099835925 #C(-2.3025599 3.1415927) -2.5182962e-6 -2.5182962e-6 #C(-12.891928 3.1415927) 0.09999748 0.09983091 -2.3026102 0.19999748 0.19866687 -1.6094505 0.29999748 0.2955178 -1.2039812 0.39999747 0.389416 -0.9162971 0.49999747 0.4794233 -0.69315225 0.59999746 0.5646404 -0.51082987 0.6999975 0.64421576 -0.35667855 0.7999975 0.71735436 -0.22314666 0.89999753 0.7833254 -0.10536326 0.99999756 0.84146965 -2.4437934e-6 1.0999975 0.89120626 0.095307924 1.1999975 0.9320382 0.1823195 1.2999976 0.96355754 0.2623624 1.3999976 0.9854493 0.3364705 1.4999976 0.9974948 0.40546352 1.5999976 0.99957365 0.47000214 1.6999977 0.9916651 0.5306269 1.7999977 0.97384816 0.58778536 1.8999977 0.9463008 0.6418527 1.9999977 0.90929836 0.69314605 2.0999978 0.8632105 0.74193627 2.1999977 0.8084978 0.7884563 2.2999976 0.74570686 0.8329081 2.3999975 0.67546505 0.87546766 2.4999974 0.59847426 0.9162897 2.5999973 0.5155037 0.9555104 2.6999972 0.4273824 0.9932507 2.799997 0.3349909 1.0296184 2.899997 0.23925224 1.0647097 2.999997 0.14112307 1.0986112 3.0999968 0.041583855 1.1314011 3.1999967 -0.05837086 1.1631498 3.2999966 -0.15774235 1.1939214 3.3999965 -0.25553775 1.2237744 3.4999964 -0.3507799 1.252762 3.5999963 -0.44251716 1.2809328 3.6999962 -0.52983296 1.3083318 3.7999961 -0.61185485 1.335 3.899996 -0.6877633 1.3609755 3.999996 -0.7567998 1.3862933 4.099996 -0.81827486 1.4109861 4.199996 -0.8715738 1.4350836 4.299996 -0.9161643 1.4586141 4.399996 -0.9516008 1.4816036 4.4999957 -0.9775292 1.5040765 4.5999956 -0.9936905 1.5260553 4.6999955 -0.9999232 1.5475615 4.7999954 -0.99616504 1.568615 4.8999953 -0.98245347 1.5892342 4.999995 -0.9589256 1.609437 end -5 0.9589243 #C(1.609438 3.1415927) -4.9 0.9824526 #C(1.5892352 3.1415927) -4.8 0.9961646 #C(1.5686159 3.1415927) -4.7000003 0.9999233 #C(1.5475626 3.1415927) -4.6000004 0.993691 #C(1.5260564 3.1415927) -4.5000005 0.97753024 #C(1.5040776 3.1415927) -4.4000006 0.9516022 #C(1.4816047 3.1415927) -4.3000007 0.9161662 #C(1.4586152 3.1415927) -4.200001 0.87157613 #C(1.4350847 3.1415927) -4.100001 0.8182776 #C(1.4109871 3.1415927) -4.000001 0.7568031 #C(1.3862946 3.1415927) -3.900001 0.6877669 #C(1.3609768 3.1415927) -3.8000011 0.6118588 #C(1.3350013 3.1415927) -3.7000012 0.5298372 #C(1.3083332 3.1415927) -3.6000013 0.44252163 #C(1.2809342 3.1415927) -3.5000014 0.35078457 #C(1.2527634 3.1415927) -3.4000015 0.25554258 #C(1.2237759 3.1415927) -3.3000016 0.1577473 #C(1.193923 3.1415927) -3.2000017 0.058375858 #C(1.1631514 3.1415927) -3.1000018 -0.04157885 #C(1.1314027 3.1415927) -3.000002 -0.14111812 #C(1.0986129 3.1415927) -2.900002 -0.23924738 #C(1.0647115 3.1415927) -2.800002 -0.33498618 #C(1.0296202 3.1415927) -2.7000022 -0.4273779 #C(0.9932526 3.1415927) -2.6000023 -0.5154994 #C(0.95551234 3.1415927) -2.5000024 -0.5984702 #C(0.9162917 3.1415927) -2.4000025 -0.67546135 #C(0.87546974 3.1415927) -2.3000026 -0.7457035 #C(0.83291024 3.1415927) -2.2000027 -0.8084948 #C(0.7884586 3.1415927) -2.1000028 -0.863208 #C(0.74193865 3.1415927) -2.0000029 -0.9092962 #C(0.6931486 3.1415927) -1.9000028 -0.9462992 #C(0.64185536 3.1415927) -1.8000028 -0.973847 #C(0.5877882 3.1415927) -1.7000028 -0.99166447 #C(0.5306299 3.1415927) -1.6000028 -0.9995735 #C(0.47000536 3.1415927) -1.5000027 -0.9974952 #C(0.40546694 3.1415927) -1.4000027 -0.9854502 #C(0.33647418 3.1415927) -1.3000027 -0.9635589 #C(0.26236632 3.1415927) -1.2000027 -0.93204004 #C(0.18232378 3.1415927) -1.1000026 -0.8912086 #C(0.09531259 3.1415927) -1.0000026 -0.8414724 #C(2.622601e-6 3.1415927) -0.9000026 -0.78332853 #C(-0.105357625 3.1415927) -0.8000026 -0.7173579 #C(-0.22314033 3.1415927) -0.70000255 -0.64421964 #C(-0.3566713 3.1415927) -0.6000025 -0.5646446 #C(-0.5108214 3.1415927) -0.5000025 -0.47942773 #C(-0.6931422 3.1415927) -0.4000025 -0.38942066 #C(-0.91628444 3.1415927) -0.30000252 -0.2955226 #C(-1.2039645 3.1415927) -0.20000252 -0.1986718 #C(-1.6094253 3.1415927) -0.10000252 -0.099835925 #C(-2.3025599 3.1415927) -2.5182962e-6 -2.5182962e-6 #C(-12.891928 3.1415927) 0.09999748 0.09983091 -2.3026102 0.19999748 0.19866687 -1.6094505 0.29999748 0.2955178 -1.2039812 0.39999747 0.389416 -0.9162971 0.49999747 0.4794233 -0.69315225 0.59999746 0.5646404 -0.51082987 0.6999975 0.64421576 -0.35667855 0.7999975 0.71735436 -0.22314666 0.89999753 0.7833254 -0.10536326 0.99999756 0.84146965 -2.4437934e-6 1.0999975 0.89120626 0.095307924 1.1999975 0.9320382 0.1823195 1.2999976 0.96355754 0.2623624 1.3999976 0.9854493 0.3364705 1.4999976 0.9974948 0.40546352 1.5999976 0.99957365 0.47000214 1.6999977 0.9916651 0.5306269 1.7999977 0.97384816 0.58778536 1.8999977 0.9463008 0.6418527 1.9999977 0.90929836 0.69314605 2.0999978 0.8632105 0.74193627 2.1999977 0.8084978 0.7884563 2.2999976 0.74570686 0.8329081 2.3999975 0.67546505 0.87546766 2.4999974 0.59847426 0.9162897 2.5999973 0.5155037 0.9555104 2.6999972 0.4273824 0.9932507 2.799997 0.3349909 1.0296184 2.899997 0.23925224 1.0647097 2.999997 0.14112307 1.0986112 3.0999968 0.041583855 1.1314011 3.1999967 -0.05837086 1.1631498 3.2999966 -0.15774235 1.1939214 3.3999965 -0.25553775 1.2237744 3.4999964 -0.3507799 1.252762 3.5999963 -0.44251716 1.2809328 3.6999962 -0.52983296 1.3083318 3.7999961 -0.61185485 1.335 3.899996 -0.6877633 1.3609755 3.999996 -0.7567998 1.3862933 4.099996 -0.81827486 1.4109861 4.199996 -0.8715738 1.4350836 4.299996 -0.9161643 1.4586141 4.399996 -0.9516008 1.4816036 4.4999957 -0.9775292 1.5040765 4.5999956 -0.9936905 1.5260553 4.6999955 -0.9999232 1.5475615 4.7999954 -0.99616504 1.568615 4.8999953 -0.98245347 1.5892342 4.999995 -0.9589256 1.609437 end -5 0.9589243 #C(1.609438 3.1415927) -4.9 0.9824526 #C(1.5892352 3.1415927) -4.8 0.9961646 #C(1.5686159 3.1415927) -4.7000003 0.9999233 #C(1.5475626 3.1415927) -4.6000004 0.993691 #C(1.5260564 3.1415927) -4.5000005 0.97753024 #C(1.5040776 3.1415927) -4.4000006 0.9516022 #C(1.4816047 3.1415927) -4.3000007 0.9161662 #C(1.4586152 3.1415927) -4.200001 0.87157613 #C(1.4350847 3.1415927) -4.100001 0.8182776 #C(1.4109871 3.1415927) -4.000001 0.7568031 #C(1.3862946 3.1415927) -3.900001 0.6877669 #C(1.3609768 3.1415927) -3.8000011 0.6118588 #C(1.3350013 3.1415927) -3.7000012 0.5298372 #C(1.3083332 3.1415927) -3.6000013 0.44252163 #C(1.2809342 3.1415927) -3.5000014 0.35078457 #C(1.2527634 3.1415927) -3.4000015 0.25554258 #C(1.2237759 3.1415927) -3.3000016 0.1577473 #C(1.193923 3.1415927) -3.2000017 0.058375858 #C(1.1631514 3.1415927) -3.1000018 -0.04157885 #C(1.1314027 3.1415927) -3.000002 -0.14111812 #C(1.0986129 3.1415927) -2.900002 -0.23924738 #C(1.0647115 3.1415927) -2.800002 -0.33498618 #C(1.0296202 3.1415927) -2.7000022 -0.4273779 #C(0.9932526 3.1415927) -2.6000023 -0.5154994 #C(0.95551234 3.1415927) -2.5000024 -0.5984702 #C(0.9162917 3.1415927) -2.4000025 -0.67546135 #C(0.87546974 3.1415927) -2.3000026 -0.7457035 #C(0.83291024 3.1415927) -2.2000027 -0.8084948 #C(0.7884586 3.1415927) -2.1000028 -0.863208 #C(0.74193865 3.1415927) -2.0000029 -0.9092962 #C(0.6931486 3.1415927) -1.9000028 -0.9462992 #C(0.64185536 3.1415927) -1.8000028 -0.973847 #C(0.5877882 3.1415927) -1.7000028 -0.99166447 #C(0.5306299 3.1415927) -1.6000028 -0.9995735 #C(0.47000536 3.1415927) -1.5000027 -0.9974952 #C(0.40546694 3.1415927) -1.4000027 -0.9854502 #C(0.33647418 3.1415927) -1.3000027 -0.9635589 #C(0.26236632 3.1415927) -1.2000027 -0.93204004 #C(0.18232378 3.1415927) -1.1000026 -0.8912086 #C(0.09531259 3.1415927) -1.0000026 -0.8414724 #C(2.622601e-6 3.1415927) -0.9000026 -0.78332853 #C(-0.105357625 3.1415927) -0.8000026 -0.7173579 #C(-0.22314033 3.1415927) -0.70000255 -0.64421964 #C(-0.3566713 3.1415927) -0.6000025 -0.5646446 #C(-0.5108214 3.1415927) -0.5000025 -0.47942773 #C(-0.6931422 3.1415927) -0.4000025 -0.38942066 #C(-0.91628444 3.1415927) -0.30000252 -0.2955226 #C(-1.2039645 3.1415927) -0.20000252 -0.1986718 #C(-1.6094253 3.1415927) -0.10000252 -0.099835925 #C(-2.3025599 3.1415927) -2.5182962e-6 -2.5182962e-6 #C(-12.891928 3.1415927) 0.09999748 0.09983091 -2.3026102 0.19999748 0.19866687 -1.6094505 0.29999748 0.2955178 -1.2039812 0.39999747 0.389416 -0.9162971 0.49999747 0.4794233 -0.69315225 0.59999746 0.5646404 -0.51082987 0.6999975 0.64421576 -0.35667855 0.7999975 0.71735436 -0.22314666 0.89999753 0.7833254 -0.10536326 0.99999756 0.84146965 -2.4437934e-6 1.0999975 0.89120626 0.095307924 1.1999975 0.9320382 0.1823195 1.2999976 0.96355754 0.2623624 1.3999976 0.9854493 0.3364705 1.4999976 0.9974948 0.40546352 1.5999976 0.99957365 0.47000214 1.6999977 0.9916651 0.5306269 1.7999977 0.97384816 0.58778536 1.8999977 0.9463008 0.6418527 1.9999977 0.90929836 0.69314605 2.0999978 0.8632105 0.74193627 2.1999977 0.8084978 0.7884563 2.2999976 0.74570686 0.8329081 2.3999975 0.67546505 0.87546766 2.4999974 0.59847426 0.9162897 2.5999973 0.5155037 0.9555104 2.6999972 0.4273824 0.9932507 2.799997 0.3349909 1.0296184 2.899997 0.23925224 1.0647097 2.999997 0.14112307 1.0986112 3.0999968 0.041583855 1.1314011 3.1999967 -0.05837086 1.1631498 3.2999966 -0.15774235 1.1939214 3.3999965 -0.25553775 1.2237744 3.4999964 -0.3507799 1.252762 3.5999963 -0.44251716 1.2809328 3.6999962 -0.52983296 1.3083318 3.7999961 -0.61185485 1.335 3.899996 -0.6877633 1.3609755 3.999996 -0.7567998 1.3862933 4.099996 -0.81827486 1.4109861 4.199996 -0.8715738 1.4350836 4.299996 -0.9161643 1.4586141 4.399996 -0.9516008 1.4816036 4.4999957 -0.9775292 1.5040765 4.5999956 -0.9936905 1.5260553 4.6999955 -0.9999232 1.5475615 4.7999954 -0.99616504 1.568615 4.8999953 -0.98245347 1.5892342 4.999995 -0.9589256 1.609437 end -5 0.9589243 #C(1.609438 3.1415927) -4.9 0.9824526 #C(1.5892352 3.1415927) -4.8 0.9961646 #C(1.5686159 3.1415927) -4.7000003 0.9999233 #C(1.5475626 3.1415927) -4.6000004 0.993691 #C(1.5260564 3.1415927) -4.5000005 0.97753024 #C(1.5040776 3.1415927) -4.4000006 0.9516022 #C(1.4816047 3.1415927) -4.3000007 0.9161662 #C(1.4586152 3.1415927) -4.200001 0.87157613 #C(1.4350847 3.1415927) -4.100001 0.8182776 #C(1.4109871 3.1415927) -4.000001 0.7568031 #C(1.3862946 3.1415927) -3.900001 0.6877669 #C(1.3609768 3.1415927) -3.8000011 0.6118588 #C(1.3350013 3.1415927) -3.7000012 0.5298372 #C(1.3083332 3.1415927) -3.6000013 0.44252163 #C(1.2809342 3.1415927) -3.5000014 0.35078457 #C(1.2527634 3.1415927) -3.4000015 0.25554258 #C(1.2237759 3.1415927) -3.3000016 0.1577473 #C(1.193923 3.1415927) -3.2000017 0.058375858 #C(1.1631514 3.1415927) -3.1000018 -0.04157885 #C(1.1314027 3.1415927) -3.000002 -0.14111812 #C(1.0986129 3.1415927) -2.900002 -0.23924738 #C(1.0647115 3.1415927) -2.800002 -0.33498618 #C(1.0296202 3.1415927) -2.7000022 -0.4273779 #C(0.9932526 3.1415927) -2.6000023 -0.5154994 #C(0.95551234 3.1415927) -2.5000024 -0.5984702 #C(0.9162917 3.1415927) -2.4000025 -0.67546135 #C(0.87546974 3.1415927) -2.3000026 -0.7457035 #C(0.83291024 3.1415927) -2.2000027 -0.8084948 #C(0.7884586 3.1415927) -2.1000028 -0.863208 #C(0.74193865 3.1415927) -2.0000029 -0.9092962 #C(0.6931486 3.1415927) -1.9000028 -0.9462992 #C(0.64185536 3.1415927) -1.8000028 -0.973847 #C(0.5877882 3.1415927) -1.7000028 -0.99166447 #C(0.5306299 3.1415927) -1.6000028 -0.9995735 #C(0.47000536 3.1415927) -1.5000027 -0.9974952 #C(0.40546694 3.1415927) -1.4000027 -0.9854502 #C(0.33647418 3.1415927) -1.3000027 -0.9635589 #C(0.26236632 3.1415927) -1.2000027 -0.93204004 #C(0.18232378 3.1415927) -1.1000026 -0.8912086 #C(0.09531259 3.1415927) -1.0000026 -0.8414724 #C(2.622601e-6 3.1415927) -0.9000026 -0.78332853 #C(-0.105357625 3.1415927) -0.8000026 -0.7173579 #C(-0.22314033 3.1415927) -0.70000255 -0.64421964 #C(-0.3566713 3.1415927) -0.6000025 -0.5646446 #C(-0.5108214 3.1415927) -0.5000025 -0.47942773 #C(-0.6931422 3.1415927) -0.4000025 -0.38942066 #C(-0.91628444 3.1415927) -0.30000252 -0.2955226 #C(-1.2039645 3.1415927) -0.20000252 -0.1986718 #C(-1.6094253 3.1415927) -0.10000252 -0.099835925 #C(-2.3025599 3.1415927) -2.5182962e-6 -2.5182962e-6 #C(-12.891928 3.1415927) 0.09999748 0.09983091 -2.3026102 0.19999748 0.19866687 -1.6094505 0.29999748 0.2955178 -1.2039812 0.39999747 0.389416 -0.9162971 0.49999747 0.4794233 -0.69315225 0.59999746 0.5646404 -0.51082987 0.6999975 0.64421576 -0.35667855 0.7999975 0.71735436 -0.22314666 0.89999753 0.7833254 -0.10536326 0.99999756 0.84146965 -2.4437934e-6 1.0999975 0.89120626 0.095307924 1.1999975 0.9320382 0.1823195 1.2999976 0.96355754 0.2623624 1.3999976 0.9854493 0.3364705 1.4999976 0.9974948 0.40546352 1.5999976 0.99957365 0.47000214 1.6999977 0.9916651 0.5306269 1.7999977 0.97384816 0.58778536 1.8999977 0.9463008 0.6418527 1.9999977 0.90929836 0.69314605 2.0999978 0.8632105 0.74193627 2.1999977 0.8084978 0.7884563 2.2999976 0.74570686 0.8329081 2.3999975 0.67546505 0.87546766 2.4999974 0.59847426 0.9162897 2.5999973 0.5155037 0.9555104 2.6999972 0.4273824 0.9932507 2.799997 0.3349909 1.0296184 2.899997 0.23925224 1.0647097 2.999997 0.14112307 1.0986112 3.0999968 0.041583855 1.1314011 3.1999967 -0.05837086 1.1631498 3.2999966 -0.15774235 1.1939214 3.3999965 -0.25553775 1.2237744 3.4999964 -0.3507799 1.252762 3.5999963 -0.44251716 1.2809328 3.6999962 -0.52983296 1.3083318 3.7999961 -0.61185485 1.335 3.899996 -0.6877633 1.3609755 3.999996 -0.7567998 1.3862933 4.099996 -0.81827486 1.4109861 4.199996 -0.8715738 1.4350836 4.299996 -0.9161643 1.4586141 4.399996 -0.9516008 1.4816036 4.4999957 -0.9775292 1.5040765 4.5999956 -0.9936905 1.5260553 4.6999955 -0.9999232 1.5475615 4.7999954 -0.99616504 1.568615 4.8999953 -0.98245347 1.5892342 4.999995 -0.9589256 1.609437 end set output"
(defun using-unicode-characters-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :samples 500)
(gp :set :encoding 'utf8)
(gp :set :title "favorite graph of ǫrnólfr þórðr")
'font
"helvetica, 24"
(plot "[0:10] sin(1/x)"))
output)
(png-from-file
(using-unicode-characters-plot "images/using-unicode-characters-plot.png"))
USING-UNICODE-CHARACTERS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun coloring-curves-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo solid lw 4) :xrange '(0 1))
(gp :set :border '(lw 0.25))
(gp :set :key '(top left))
(plot
"x**0.5" :lc '(rgb "orange"))
(plot
"x" :lc '(rgb "steelblue"))
(plot
"x**2" :lc '(rgb "bisque"))
(plot
"x**3" :lc '(rgb "seagreen")))
output)
(png-from-file (coloring-curves-plot "images/coloring-curves-plot.png"))
COLORING-CURVES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun styling-curves-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo solid lw 4) :xrange '(0 1))
(gp :set :key '(top left))
(gp :set :style '(:line 1 lt 3 lw 4 lc rgb ("'#990042'")))
(gp :set :style '(:line 2 lt 7 lw 3 lc rgb ("'#31f120'")))
(gp :set :style '(:line 3 lt 2 lw 3 lc rgb ("'#0044a5'")))
(gp :set :style '(:line 4 lt 9 lw 4 lc rgb ("'#888888'")))
(plot "x**0.5" :ls 1)
(plot "x" :ls 2)
(plot "x**2" :ls 3)
(plot "x**3" :ls 4))
output)
(png-from-file (styling-curves-plot "images/styling-curves-plot.png"))
STYLING-CURVES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun styling-curves--userstyles-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo solid lw 4) :xrange '(0 1))
(gp :set :key '(top left))
(gp :set :style '(increment userstyles))
(gp :set :style '(:line 1 lt 3 lw 4 lc rgb ("'#990042'")))
(gp :set :style '(:line 2 lt 7 lw 3 lc rgb ("'#31f120'")))
(gp :set :style '(:line 3 lt 2 lw 3 lc rgb ("'#0044a5'")))
(gp :set :style '(:line 4 lt 9 lw 4 lc rgb ("'#888888'")))
(plot "x**0.5")
(plot "x" )
(plot "x**2" )
(plot "x**3" ))
output)
(png-from-file
(styling-curves--userstyles-plot
"images/styling-curves--userstyles-plot.png"))
STYLING-CURVES--USERSTYLES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun transparency-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :style '(fill transparent solid 0.3))
(plot
"[0:pi] sin(x)**2 with filledcurves above y1=0 lc rgb '#00ffff', 0.75*cos(2*x)**2 with filledcurves above y1=0 lc rgb '#aa00aa'"))
output)
(png-from-file (transparency-plot "images/transparency-plot.png"))
TRANSPARENCY-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun plotting-points-with-curves-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(plot "sin(x)/x with linespoints ps 2 pt 6"))
output)
(png-from-file
(plotting-points-with-curves-plot
"images/plotting-points-with-curves-plot.png"))
PLOTTING-POINTS-WITH-CURVES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun changing-the-point-style-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :key '(top left))
(gp :set :style '#'linespoints)
(gp :set :style '(line 1 lw 4 lc rgb ("'#990042'") ps 2 pt 6 pi 5))
(gp :set :style '(line 2 lw 3 lc rgb ("'#31f120'") ps 2 pt 12 pi 3))
(gp :set :style '(line 3 lw 3 lc rgb ("'#0044a5'") ps 2 pt 9 pi 5))
(gp :set :style '(line 4 lw 4 lc rgb ("'#888888'") ps 2 pt 7 pi 4))
(plot "[0:1] x**0.5 ls 1, x ls 2, x**2 ls 3, x**3 ls 4"))
output)
(png-from-file
(changing-the-point-style-plot "images/changing-the-point-style-plot.png"))
CHANGING-THE-POINT-STYLE-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun plotting-with-objects-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo) :object
'(1 circle at graph |0.5 , 0.5| size graph 0.25 fillcolor rgb
("'blue'") fillstyle solid arc |[0:30]| front)
:object
'(2 circle at graph |0.5 , 0.5| size graph 0.25 fillcolor rgb
("'red'") fillstyle solid arc |[30:80]| front)
:object
'(3 circle at graph |0.5 , 0.5| size graph 0.25 fillcolor rgb
("'orange'") fillstyle solid arc |[80:180]| front)
:object
'(4 circle at graph |0.5 , 0.5| size graph 0.25 fillcolor rgb
("'green'") fillstyle solid arc |[180:240]| front)
:object
'(5 circle at graph |0.5 , 0.5| size graph 0.25 fillcolor rgb
("'sandybrown'") fillstyle solid arc |[240:360]| front))
(gp :unset :key)
(gp :unset :tics)
(plot "[0:1][0:1] -1"))
output)
(png-from-file
(plotting-with-objects-plot "images/plotting-with-objects-plot.png"))
PLOTTING-WITH-OBJECTS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun adding-minor-tics-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :grid 'nil)
(gp :set :mxtics 4)
(gp :set :mytics 2)
(plot "[0:2*pi] sin(12*x)*exp(-x/4)"))
output)
(png-from-file (adding-minor-tics-plot "images/adding-minor-tics-plot.png"))
ADDING-MINOR-TICS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun placing-tics-on-second-y-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo)) ;
(gp :set :ytics 'nomirror)
(gp :set :y2tics 0.4)
(gp :set :xtics '("pi/4."))
(plot "[0:2*pi] sin(x) axis x1y1, 2*cos(8*x)*exp(-x) axis x1y2"))
output)
(png-from-file
(placing-tics-on-second-y-axis-plot
"images/placing-tics-on-second-y-axis-plot.png"))
PLACING-TICS-ON-SECOND-Y-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun adjusting-the-tic-size-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo)) ;
(gp :set :tics '(scale 3))
(gp :set :mxtics 4)
(gp :set :mytics 4)
(plot "[0:4*pi] sin(x)/x"))
output)
(png-from-file
(adjusting-the-tic-size-plot "images/adjusting-the-tic-size-plot.png"))
ADJUSTING-THE-TIC-SIZE-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun removing-all-tics-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :tics)
(plot "[0:2*pi] x**2*sin(x)"))
output)
(png-from-file (removing-all-tics-plot "images/removing-all-tics-plot.png"))
REMOVING-ALL-TICS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun defining-tic-values-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo)) ;
(gp :unset :border)
(gp :set :xtics :axis :nomirror)
(gp :set :ytics :axis :nomirror)
(gp :set :zeroaxis)
(gp :set :polar)
(gp :set :samples 500)
(gp :set :grid)
(gp :unset :raxis)
(gp :set :xtics '(15 2 30))
(gp :set :ytics '(10 2 20))
(plot "[0:12*pi] t"))
output)
(png-from-file
(defining-tic-values-plot "images/defining-tic-values-plot.png"))
DEFINING-TIC-VALUES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun making-the-tics-stick-out-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :tics 'out)
(gp :set :grid 'nil)
(plot "[-3:3] tanh(x)"))
output)
(png-from-file
(making-the-tics-stick-out-plot "images/making-the-tics-stick-out-plot.png"))
MAKING-THE-TICS-STICK-OUT-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun setting-manual-tics-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :xtics '|('pi' pi, 'pi/2' pi/2, '2pi' 2*pi, '3pi/2' 3*pi/2, "0" 0)|)
(plot "[0:2*pi] sin(x)"))
output)
(png-from-file
(setting-manual-tics-plot "images/setting-manual-tics-plot.png"))
SETTING-MANUAL-TICS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun setting-manual-tics-enhanced-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo enhanced))
(gp :set :xtics '|('{/symbol p}' pi, '{/symbol p}/2' pi/2, '2{/symbol p}' 2*pi, '3{/symbol p}/2' 3*pi/2, "0" 0)|)
(plot "[0:2*pi] sin(x)"))
output)
(png-from-file
(setting-manual-tics-enhanced-plot
"images/setting-manual-tics-enhanced-plot.png")
)
SETTING-MANUAL-TICS-ENHANCED-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun setting-manual-tics-enhanced-add-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo enhanced))
(gp :set :xtics :add '|('{/symbol p}' pi, '2{/symbol p}' 2*pi)|)
(plot "[0:2*pi] sin(x)"))
output)
(png-from-file
(setting-manual-tics-enhanced-add-plot
"images/setting-manual-tics-enhanced-add-plot.png"))
SETTING-MANUAL-TICS-ENHANCED-ADD-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun plotting-with-dates-and-times-plot (output)
(let ((datastream
(clml.utility.data:fetch
"https://mmaul.github.io/clml.data/sample/traffic-balance.csv"
:stream t)))
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(gp :set :title "interface utilization")
(gp :set :xdata 'time)
(gp :set :timefmt "%y/%m/%d:%h:%m:%s")
(gp :set :format '(x "%d/%m/%y"))
(gp :set :xtics '(rotate))
(gp :unset :key)
(let ((data (subseq (clml.utility.csv:read-csv-stream datastream :type-spec '(string float float float float float float))
0 1000)))
(plot
(lambda ()
(loop for row across data
do (format s "~&~a ~{~a~^ ~}"
(map 'string
(lambda (x)
(if (equal #\ x)
#\:
x))
(elt row 0))
(coerce (subseq row 1) 'list))))
:using '(0 5) :with 'lines))))
output)
(png-from-file
(plotting-with-dates-and-times-plot
"images/plotting-with-dates-and-times-plot.png"))
PLOTTING-WITH-DATES-AND-TIMES-PLOT
The plot below requires gnuplot version 5
(defun changing-language-used-in-labels-plot (output)
(let ((datastream
(clml.utility.data:fetch
"https://mmaul.github.io/clml.data/sample/traffic-balance.csv"
:stream t)))
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(gp :set :title "interface utilization")
(gp :set :xdata 'time)
(gp :set :locale "es_ES.utf8")
(gp :set :timefmt "%y/%m/%d:%h:%m:%s")
(gp :set :format '(x "%b %y"))
(gp :set :xtics '(rotate))
(gp :unset :key)
(plot
(lambda ()
(loop for row across (subseq
(clml.utility.csv:read-csv-stream datastream :type-spec
'(string float
float
float
float
float
float))
0 10)
do (format s "~&~a ~{~a~^ ~}"
(map 'string
(lambda (x)
(if (equal #\ x)
#\:
x))
(elt row 0))
(coerce (subseq row 1) 'list))))
:using '(0 5) :with 'lines)))
output)
(png-from-file
(changing-language-used-in-labels-plot
"images/changing-language-used-in-labels-plot.png"))
CHANGING-LANGUAGE-USED-IN-LABELS-PLOT
The plot below requires gnuplot version 5
(defun using-european-style-decimals-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :decimalsign '(locale "es_ES.utf8"))
(plot "[0:1] x**3"))
output)
(png-from-file
(using-european-style-decimals-plot
"images/using-european-style-decimals-plot.png"))
USING-EUROPEAN-STYLE-DECIMALS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun formatting-tic-labels-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :ylabel "output power")
(gp :set :format '(y "p = %.2f watts"))
(gp :set :format '(x "%.3f%%"))
(gp :set :rmargin 6)
(plot "[0:1] x**3"))
output)
(png-from-file
(formatting-tic-labels-plot "images/formatting-tic-labels-plot.png"))
FORMATTING-TIC-LABELS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun tic-no-labels-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo enhanced))
(gp :set :ylabel "output power")
(gp :set :format '(y ""))
(gp :set :format '(x ""))
(gp :set :grid)
(gp :unset :key)
(plot "x, -x"))
output)
(png-from-file (tic-no-labels-plot "images/tic-no-labels-plot.png"))
TIC-NO-LABELS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun multiplot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "multiplot"
:multiplot (list "layout 2,2 columnsfirst title \"multiplot\""))
(plot "besj0(x)")
(plot "besj1(x)")
(plot "besy0(x)")
(plot "besy1(x)")
(gp :unset 'multiplot))
output)
(png-from-file (multiplot "images/multiplot.png"))
MULTIPLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun stem-multiplot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(:pngcairo) :title "candlestick"
:xrange '(0 5) :yrange '(0 25) :multiplot
(list "layout 2,1 columnsfirst title \"multiplot stem\""))
(flet ((data ()
(loop for r in '((1 5 7 10 15 24 0.3 "quick")
(2 6 8 11 16 23 0.4 "fox")
(3 5 7 11 17 22 0.5 "lazy")
(4 6 9 10 18 21 0.3 "dog"))
do (format s "~&~{~^~a ~}" r))))
(plot #'data :using '(1 6 |xticlabels(8)|) :with :impulses :lw 4 :title "counts")
(plot #'data :using '(1 6) :with :points :pt 9 :notitle ())
(gp :unset 'multiplot)))
output)
(png-from-file (stem-multiplot "images/stem-multiplot.png"))
STEM-MULTIPLOT
(defun plot-positioning-plot (output)
(with-plots (s :debug t)
(gp-setup :output output :terminal '(:pngcairo) :multiplot (list ""))
(gp :set :title "o o")
(gp :set :polar 'nil)
(gp :set :size (list "1,.5"))
(gp :set :border 0)
(gp :unset :key)
(gp :unset :tics)
(gp :unset :raxis)
(plot "[pi:2*pi] -1" :lw 5)
(gp :set :title "###################")
(gp :set :origin (list "0,.5"))
(gp :set :size (list ".5, .5"))
(plot "-2*pi" :lw (list "2, .2") :with 'filledcurves)
(gp :set :origin (list ".5, .5"))
(gp :set :title "###################")
(plot "1" :lw (list "2, .2") :with 'filledcurves)
(gp :unset 'multiplot))
output)
(png-from-file (plot-positioning-plot "images/plot-positioning.png"))
PLOT-POSITIONING-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
" set terminal pngcairo set output \"images/plot-positioning.png\" set multiplot set title \"o o\" set polar set size 1,.5 set border 0 unset key unset tics unset raxis plot [pi:2*pi] -1 lw 5 plot -2*pi lw 2, .2 with filledcurves plot 1 lw 2, .2 with filledcurves set title \"###################\" set origin 0,.5 set size .5, .5 set origin .5, .5 set title \"###################\" unset multiplot set output"
(defun inset-plot (output)
(with-plots (s :debug t)
(gp-setup :output output :terminal '(:pngcairo) :multiplot (list ""))
(gp :set :object :ellipse :center '(0.13 0) :size '(0.4 4))
(gp :set :arrow :from '(0.1 2.1) :to :screen '(0.22 0.4) :front :lt 3 :lw 3)
(gp :set :samples 1000)
(gp :set :grid 'nil)
(gp :set :xtics 0.4)
(gp :set :ytics 4)
(plot "[0:2*pi] exp(x)*sin(1/x)")
(gp :set :origin '(0.2 0.4))
(gp :set :size '(0.25 0.25))
(gp :clear)
(gp :unset :grid)
(gp :unset :object)
(gp :unset :arrow)
(gp :set :xtics 0.1)
(gp :set :ytics 0.5)
(gp :set :bmargin 1)
(gp :set :tmargin 1)
(gp :set :lmargin 3)
(gp :set :rmargin 1)
(plot "[0:.2] exp(x)*sin(1/x)")
(gp :unset 'multiplot))
output)
(png-from-file (inset-plot "images/inset-plot.png"))
INSET-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
" set terminal pngcairo set output \"images/inset-plot.png\" set multiplot set object ellipse center 0.13,0 size 0.4,4 set arrow from 0.1,2.1 to screen 0.22,0.4 front lt 3 lw 3 set samples 1000 set grid set xtics 0.4 set ytics 4 plot [0:2*pi] exp(x)*sin(1/x) plot [0:.2] exp(x)*sin(1/x) set origin 0.2,0.4 set size 0.25,0.25 clear unset grid unset object unset arrow set xtics 0.1 set ytics 0.5 set bmargin 1 set tmargin 1 set lmargin 3 set rmargin 1 unset multiplot set output"
(defun multiplot-w-labels-and-arrows (output)
(with-plots (s :debug t)
(gp-setup :output output
:terminal '(pngcairo)
:title "derivatives of sin(x)"
:font "times-roman, 22")
(gp :set :multiplot :layout '(2 2))
(gp :unset :key)
(gp :set :xrange '(-pi pi))
(gp :set :arrow
:from '(0.1 2.1) :to :screen '(0.22 0.4) :front :lt 3)
(gp :set :style
:arrow 1 :head :filled :size :screen '(0.03 15 135) :lt 2 :lw 2)
(gp :set :arrow
:from :screen '(0.45 0.84) :to :screen '(0.65 0.84) :arrowstyle 1)
(gp :set :arrow
:from :screen '(0.87 0.64) :to :screen '(0.87 0.3) :arrowstyle 1)
(gp :set :arrow
:from :screen '(0.7 0.15) :to :screen '(0.4 0.15) :arrowstyle 1)
(gp :set :arrow
:from :screen '(0.35 0.35) :to :screen '(0.35 0.7) :arrowstyle 1)
(gp :set :title "sin(x)")
(plot "sin(x)")
(gp :set :title "sin'(x) = cos(x)")
(plot "cos(x)")
(gp :set :title "sin'''(x) = cos''(x) = -sin'(x) = -cos(x)")
(plot "-cos(x)")
(gp :set :title "sin''(x) = cos'(x) = -sin(x)")
(plot "-sin(x)")
(gp :unset :multiplot))
output)
(png-from-file
(multiplot-w-labels-and-arrows "images/multiplot-w-labels-and-arrows.png"))
MULTIPLOT-W-LABELS-AND-ARROWS
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
" set terminal pngcairo set output \"images/multiplot-w-labels-and-arrows.png\" set title \"derivatives of sin(x)\" set font \"times-roman, 22\" set multiplot layout 2,2 unset key set xrange [-pi:pi] set arrow from 0.1,2.1 to screen 0.22,0.4 front lt 3 set style arrow 1 head filled size screen 0.03,15,135 lt 2 lw 2 set arrow from screen 0.45,0.84 to screen 0.65,0.84 arrowstyle 1 set arrow from screen 0.87,0.64 to screen 0.87,0.3 arrowstyle 1 set arrow from screen 0.7,0.15 to screen 0.4,0.15 arrowstyle 1 set arrow from screen 0.35,0.35 to screen 0.35,0.7 arrowstyle 1 set title \"sin(x)\" plot sin(x), cos(x), -cos(x), -sin(x) set title \"sin'(x) = cos(x)\" set title \"sin'''(x) = cos''(x) = -sin'(x) = -cos(x)\" set title \"sin''(x) = cos'(x) = -sin(x)\" unset multiplot set output"
(defun plotting-on-sub-intervals-plot (output)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(gp :set :samples 2000)
(gp '|f(x) = x < 0 ? sin(x) : NaN|)
(gp '|g(x) = x >= 0 ? exp(-x/5.)*sin(x) : NaN|)
(plot "[-20 : 20] f(x), g(x)"))
output)
(png-from-file
(plotting-on-sub-intervals-plot "images/plotting-on-sub-intervals-plot.png"))
PLOTTING-ON-SUB-INTERVALS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
Not working needs to repeat data section again for smoothing, but look for fix in the future
(defun smoothing-your-data-plot (output)
(let ((s
(clml.utility.data:fetch
"http://www.google.com/finance/getprices?i=60&p=10d&f=d,o,h,l,c,v&df=cpct&q=ibm"
:stream t)))
(clml.utility.data:process-finance-header s)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(plot
(lambda ()
(loop for row across (subseq
(clml.utility.csv:read-csv-stream s :type-spec
'(float float
float
float
float
float))
0 300)
do (format s "~&~{~a~^ ~}" (coerce row 'list))))
:using '(0 4) :with
'(lines lw 0.5 notitle #\, ("''") smooth bezier lw 4 title
"bezier smoothed"))))
output)
;(png-from-file
; (smoothing-your-data-plot "images/smoothing-your-data-plot.png"))
SMOOTHING-YOUR-DATA-PLOT
Not working needs to repeat data section again for smoothing, but look for fix in the future
(defun fit-functions-to-your-data-plot (output)
(let ((s
(clml.utility.data:fetch
"http://www.google.com/finance/getprices?i=60&p=10d&f=d,o,h,l,c,v&df=cpct&q=ibm"
:stream t)))
(clml.utility.data:process-finance-header s)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(format s "~&f(x) = a*sin(b*x)~%")
(format s "~&fit f(x) 'rs.dat' via a, b~%")
(plot
(lambda ()
(loop for row across (subseq
(clml.utility.csv:read-csv-stream s :type-spec
'(float float
float
float
float
float))
0 300)
do (format s "~&~{~a~^ ~}" (coerce row 'list))))
:using '(0 4) :with
'(lines lw 0.5 notitle #\, f (x) lw 4 title " fit by gnuplot"))))
output)
;(png-from-file
; (fit-functions-to-your-data-plot
; "images/fit-functions-to-your-data-plot.png"))
FIT-FUNCTIONS-TO-YOUR-DATA-PLOT
Not working needs to repeat data section again for smoothing, but look for fix in the future
(defun using-kdensity-to-improve-on-histograms-plot (output)
(let ((s
(clml.utility.data:fetch
"http://www.google.com/finance/getprices?i=60&p=10d&f=d,o,h,l,c,v&df=cpct&q=ibm"
:stream t)))
(clml.utility.data:process-finance-header s)
(with-plots (s :debug nil)
(gp-setup :terminal '(pngcairo) :output output)
(format s "~&f(x) = a*sin(b*x)~%")
(format s "~&fit f(x) 'rs.dat' via a, b~%")
(plot
(lambda ()
(loop for row across (subseq
(clml.utility.csv:read-csv-stream s :type-spec
'(float float
float
float
float
float))
0 300)
do (format s "~&~{~a~^ ~}" (coerce row 'list))))
:using '(("1:(.001)") smooth kdensity))))
output)
;(png-from-file
; (using-kdensity-to-improve-on-histograms-plot
; "images/using-kdensity-to-improve-on-histograms-plot.png"))
USING-KDENSITY-TO-IMPROVE-ON-HISTOGRAMS-PLOT
(defun 3d-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :isosamples 40)
(gp :set :title "j_0(r^2)")
(gp :set :xrange '(-4 4))
(gp :set :yrange '(-4 4))
(gp :set :ztics 1)
(gp :set :view '(29 53))
(splot "besj0(x**2+y**2)")
(format s "~&replot~%"))
output)
(png-from-file (3d-plot "images/3d-plot.png"))
3D-PLOT
(defun pm3d-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :isosamples 40)
(gp :set :title "j_0(r^2)")
(gp :set :xrange '(-4 4))
(gp :set :yrange '(-4 4))
(gp :set :ztics 1)
(gp :set :view '(29 53))
(gp :set :pm3d 'nil)
(gp :unset :surface)
(splot "besj0(x**2+y**2)")
(format s "~&replot~%"))
output)
(png-from-file (pm3d-plot "images/pm3d-plot.png"))
PM3D-PLOT
(defun pm3d2-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :isosamples 40)
(gp :set :title "j_0(r^2)")
(gp :set :xrange '(-4 4))
(gp :set :yrange '(-4 4))
(gp :set :ztics 1)
(gp :unset :surf)
(gp :set :view '(29 53))
(gp :set :style '(line 1 lt 4 lw 0.5))
(gp :set :pm3d '(at s hidden3d 1))
(splot "besj0(x**2+y**2)")
(format s "~&replot~%"))
output)
(png-from-file (pm3d2-plot "images/pm3d2-plot.png"))
PM3D2-PLOT
(defun contour-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :cntrparam '(levels 10))
(gp :set :contour 'base)
(gp :unset :sur)
(gp :set :view 'map)
(gp :set :xrange '(-4 4))
(gp :set :yrange '(-4 4))
(gp :set :iso 100)
(gp :set :samp 100)
(gp :set :key 'rmargin)
(splot "sin(x)+cos(2*y)"))
output)
(png-from-file (contour-plot "images/contour-plot.png"))
CONTOUR-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun contour-both (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :cntrparam '(levels 10))
(gp :set :style :line 1 :linecolor '(rgb "#cccccc"))
(gp :set :contour 'both)
(gp :set :hidd 'nil)
(gp :set :iso 50)
(gp :set :samp 50)
(gp :set :yrange '(-4 4))
(gp :set :xrange '(-4 4))
(splot "sin(x)+cos(2*y)" :with '(lines linestyle 1)))
output)
(png-from-file (contour-both "images/contour-both.png"))
CONTOUR-BOTH
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun vector-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :xrange '(0 pi))
(gp :set :yrange '(0 pi))
(gp :set :iso 20)
(gp :set :samp 20)
(gp :a := .2)
(gp :set :iso 50)
(gp :set :samp 50)
(gp :set :yrange '(-4 4))
(gp :set :xrange '(-4 4))
(plot "'++'" :using '(1 2 |(-a*sin($1)*cos($2)):(a*cos($1)*sin($2))|)
:with :vec :size '(0.06 15) :filled ()))
output)
(png-from-file (vector-plot "images/vector-plot.png"))
VECTOR-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::VECTOR-PLOT in DEFUN
(defun vector-contour-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :xrange '(-pi pi))
(gp :set :yrange '(-pi pi))
(gp :set :zrange '(-pi pi))
(gp :set :iso 20)
(gp :set :samp 20)
(gp :set :ztics 1.5)
(gp :set :view '(37 300))
(gp :a := .9)
(splot "'++'" :using
(list 1 2 "(2*a*cos($2)*sin($1))" "(-a*sin($1)*cos($2))"
"(a*cos($1)*sin($2))" "(a*cos($1))")
:with :vec))
output)
(png-from-file (vector-contour-plot "images/vector-contour-plot.png"))
VECTOR-CONTOUR-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::VECTOR-CONTOUR-PLOT in DEFUN
(defun image-map-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :xrange '(-4 4))
(gp :set :yrange '(-4 4))
(gp :set :iso 100)
(gp :set :samp 100)
(gp :set :view 'map)
(gp :set :pm3d '(at b))
(gp :set :palette '("defined (0 'black', 1 'gold')"))
(gp :set :logscale 'cb)
(gp :unset :surface)
(splot "sin(y**2+x**2) - cos(x**2)"))
output)
(png-from-file (image-map-plot "images/image-map-plot.png"))
IMAGE-MAP-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun contours-image-map-plot(output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo))
(gp :unset :key)
(gp :unset :surface)
(gp :set :xrange '(0 pi))
(gp :set :yrange '(0 pi))
(gp :set :iso 100)
(gp :set :samp 100)
(gp :set :cntrparam '(levels 10))
(gp :set :view 'map)
(gp :set :pm3d '(at b))
(gp :set :contour 'base)
;:palette '("defined (0 'black', 1 'gold')")
;:logscale 'cb
;:cbrange "[a : b]"
;(gp :unset :surface )
(splot "'++'"
:using '(1 2 "($1**2-$2**2)" "(sin($1**2+$2**2))")
:with :lines :lw 2))
output)
(png-from-file (contours-image-map-plot "images/contours-image-map-plot.png"))
CONTOURS-IMAGE-MAP-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::CONTOURS-IMAGE-MAP-PLOT in DEFUN
(defun surface-w-images-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :unset :key)
(gp :set :xrange '(-pi pi))
(gp :set :yrange '(-pi pi))
(gp :set :iso 40)
(gp :set :samp 40)
(gp :set :hidden 'front)
(format s "~&f(x,y) = sin(x)*cos(y)~%")
(splot "f(x,y)" :with (list "pm3d at b, f(x,y)") :with 'lines))
output)
(png-from-file (surface-w-images-plot "images/surface-w-images-plot.png"))
SURFACE-W-IMAGES-PLOT
(defun path-in-3d-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :xtics 0.4)
(gp :set :ytics 0.4)
(gp :set :parametric 'nil)
(gp :set :samp 40)
(gp :set :ztics 1)
(splot "cos(u),sin(3*u),cos(5*u)" :lw 2))
output)
(png-from-file (path-in-3d-plot "images/path-in-3d-plot.png"))
PATH-IN-3D-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::PATH-IN-3D-PLOT in DEFUN
(defun parametric-surfaces (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :param 'nil)
(gp :set :iso 50)
(gp :set :ztics 0.5)
(gp :set :xtics 0.4)
(gp :set :ytics 0.4)
(gp :set :urange '(-pi pi))
(gp :set :vrange '(-pi pi))
(gp :set :hidd 'nil)
(splot "cos(u)*cos(v), sin(u)*cos(v), sin(u)"))
output)
(png-from-file (parametric-surfaces "images/parametric-surfaces.png"))
PARAMETRIC-SURFACES
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun parametric-surfaces-depthorder (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :param 'nil)
(gp :set :iso 50)
(gp :set :ztics 0.5)
(gp :set :xtics 0.4)
(gp :set :ytics 0.4)
(gp :set :urange '(-pi pi))
(gp :set :vrange '(-pi pi))
(gp :set :hidd 'nil)
(gp :set :pm3d 'depthorder)
(splot "cos(u)*cos(v), sin(u)*cos(v), sin(u)"))
output)
(png-from-file
(parametric-surfaces-depthorder "images/parametric-surfaces-depthorder.png"))
PARAMETRIC-SURFACES-DEPTHORDER
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used.
(defun rotate-labels-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :xrange '(0 2*pi))
(gp :set :xtics '(0 0.12*pi 2*pi) :format "%.10f" :rotate :by -30)
(gp :set :rmargin 10)
(plot "sin(x)"))
output)
(png-from-file (rotate-labels-plot "images/rotate-labels-plot.png"))
ROTATE-LABELS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::ROTATE-LABELS-PLOT in DEFUN
(defun labels-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo enhanced)
:title "label plot")
(gp :set :xrange '(0 15))
(gp :set :yrange '(6 10))
(gp :unset :key)
(gp :set :rmargin 10)
(gp :set :xlabel "one thing")
(gp :set :ylabel "another")
(format s
"~&countryname(string,size) = sprintf(\"{/=%d %s}\", size, string)~%")
(plot
(lambda ()
(loop for r in '((1 5 7 10 15 24 0.3 "quick")
(2 10 8 11 20 23 0.4 "fox")
(3 9 7 11 7 22 0.5 "lazy")
(4 6 9 10 40 21 0.3 "dog"))
do (format s "~&~{~^~a ~}" r)))
:using '(2 3 |(countryname(stringcolumn(8),$5))|) :with :labels))
output)
(png-from-file (labels-plot "images/labels-plot.png"))
LABELS-PLOT
SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::LABELS-PLOT in DEFUN
(defun labeled-contour-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo)
:view :map
:contour :base
:xrange '(0 5)
:yrange '(0 5)
:style '( fill solid))
(gp :set :for '|[n = 1:4]| :cntrparam :levels :discrete :n**2)
(gp :set :for '|[n = 1:4]| :object :n :circle :at '(n n) :size 0.2 :front :fillcolor '(rgb "#ffffff") :lw 0)
(gp :set :for '|[n = 1:4]| :label :n '|sprintf("%d", n**2)| :at '(n n) :center :front)
(gp :unset :key)
(gp :unset :surf)
(gp :unset :clabel)
(splot "x*y")
)output)
(png-from-file (labeled-contour-plot "images/labeled-contour-plot.png"))
LABELED-CONTOUR-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::LABELED-CONTOUR-PLOT in DEFUN
(defun softened-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo) :style
'(line 2 lc rgb ("'#999999'") lt 0 ("#grid")) :style
'(line 1 lc rgb ("'#999999'") lt 1 ("#border")) :grid
'(linestyle 2) :border '(linestyle 1))
(gp :unset :key)
(gp :unset :surf)
(gp :unset :clabel)
(plot "sin(x)/x" :lw 2))
output)
(png-from-file (softened-axis-plot "images/softened-axis-plot.png"))
SOFTENED-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::SOFTENED-AXIS-PLOT in DEFUN
(defun arrow-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo)
:tmargin 5 :rmargin 20 :border 3 :tics 'nomirror :grid 'nil)
(gp :set :arrow
:from :graph '(0 1) :to :graph '(0 1.1) :filled)
(gp :set :arrow
:from :graph '(1 0) :to :graph '(1.1 0) :filled)
(plot "sin(x)/x" :lw 2))
output)
(png-from-file (arrow-axis-plot "images/arrow-axis-plot.png"))
ARROW-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::ARROW-AXIS-PLOT in DEFUN
(defun plotting-with-images-plot (output)
(with-plots (s :debug t)
(gp-setup :output output :terminal '(pngcairo))
(gp :set :title "elbonian warhead inventory" :font "times,24" :offset '(0 2))
(gp :set :xlabel "year" :font "times,12")
(gp :set :ylabel "number of operational warheads" :font "times,14")
(gp :set :tics :nomirror)
(gp :set :xtics :scale 0)
(gp :set :for '|[n = 0 : 3]| :ytics '|(sprintf(\"%d\" , (n*10)) 200*n)|)
(gp :set :for '|[n = 0 : 3]| :xtics '|(sprintf(\"%d\" , 1990+10*n) 91+200*n)|)
(gp :set :xtics :add '|(\"2020\\n(projected)\" 691)|)
(gp :set :cbrange '(0 250))
(gp :set :pal '(gray positive))
(gp :set :view 'map)
(gp :unset :key)
(gp :unset :colorbox)
(splot
" for [n = 0 : 3] 'images/bomb.png' binary filetype=auto center=(91+200*n, 300*0.2*(1+n), 0) dy=0.2*(1+n) with image"))
output)
(png-from-file
(plotting-with-images-plot "images/plotting-with-images-plot.png"))
PLOTTING-WITH-IMAGES-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::PLOTTING-WITH-IMAGES-PLOT in DEFUN
" set terminal pngcairo set output \"images/plotting-with-images-plot.png\" set title \"elbonian warhead inventory\" font \"times,24\" offset 0,2 set xlabel \"year\" font \"times,12\" set ylabel \"number of operational warheads\" font \"times,14\" set tics nomirror set xtics scale 0 set for [n = 0 : 3] ytics (sprintf(\"%d\" , (n*10)) 200*n) set for [n = 0 : 3] xtics (sprintf(\"%d\" , 1990+10*n) 91+200*n) set xtics add (\"2020\\n(projected)\" 691) set cbrange [0:250] set pal gray positive set view map unset key unset colorbox splot for [n = 0 : 3] 'images/bomb.png' binary filetype=auto center=(91+200*n, 300*0.2*(1+n), 0) dy=0.2*(1+n) with image set output"
(defun broken-axis-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output :terminal '(pngcairo font "times,8")
:border 2
:zeroaxis '(lt -1)
:tics 'out :samp 5000
:xrange '(0.007 .1)
:yrange '(-.05 1)
:xtics '(0.005 0.005 0.025)
;; :object '("1 fillstyle pattern 5 lw 0")
:key '(font "times,12" samplen -1))
(gp :set :xtics :axis :nomirror)
(gp :set :ytics :axis :nomirror)
(gp :unset :key)
(gp :unset :surf)
(gp :unset :clabel)
(gp :s := 0.2)
(gp :b := 0.03)
(gp :w := 0.001)
(gp :h := 1)
(gp '|h(x)| := '|sin(1/x)**2|)
(gp '|f(x)| := '|(x<b?h(x):NaN)|)
(gp '|g(x)| := '|(x>b?h(x+s):NaN)|)
(gp :set :for
'|[n = 4 : 10]|
:xtics :add '|(sprintf(\"%.3f\", s + n/100.0) n/100.0)|)
;;(gp :set :object '("1 polygon from first b-w,-h to b+w,-h to b+w,h to b-w,h to b-w,-h front"))
(plot "f(x)" :title "sin(1/x)" :lt -1)
(plot "g(x)" :notitle () :lt -1))
output)
(png-from-file (broken-axis-plot "images/broken-axis-plot.png"))
BROKEN-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::BROKEN-AXIS-PLOT in DEFUN
(defun fit-grid-to-data-plot (output)
(with-plots (s :debug nil)
(gp-setup :output output
:terminal '(pngcairo font "times,8")
:samples 6
:key '(top left))
(gp :set :for '|[n = 1 : 4]| :arrow :from :first '(n 0) :to :first '(n n**2) :back :nohead :lt 7)
(gp :set :for '|[n = 1 : 4]| :arrow :from :first '(0 n**2) :to :first '(n n**2) :back :nohead :lt 7)
(gp :set :for '|[n = 0 : 5]| :ytics '|(n**2)|)
(plot "[0:5] x**2" :with :linespoints :pt 7 :ps 3))
output)
(png-from-file (fit-grid-to-data-plot "images/fit-grid-to-data-plot.png"))
FIT-GRID-TO-DATA-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::FIT-GRID-TO-DATA-PLOT in DEFUN
(defun coloring-axis-plot (output)
(with-plots (s :debug t)
(gp-setup :output output
:terminal '(:pngcairo :font "times,8")
:multiplot (list ""))
(gp :set :tmargin '(at screen 0.8))
(gp :set :rmargin '(at screen 0.8))
(gp :set :lmargin '(at screen 0.2))
(gp :set :bmargin '(at screen 0.2))
(gp :set :tics :nomirror)
(gp :set :xrange '(0 5))
(gp :set :border 8)
(gp :set :border '(lt 4))
(gp :set :y2tics '(0 25 150))
(gp :set :y2label "exp(x)" :textcolor :lt 4)
(gp :unset :key)
(gp :unset :ytics)
(plot "exp(x)" :axis :x1y2 :lt 4)
(gp :set :border 7)
(gp :set :border :lt -1)
(gp :set :ylabel "1/x" :textcolor :lt -1)
(gp :unset :y2label)
(gp :set :ytics '(0 1 5))
(gp :set :tics 'nomirror)
(gp :unset :y2tics)
(gp :set :yrange '(0 5))
(gp :unset :y2tics)
(plot "1/x" :lt -1)
(gp :unset :multiplot))
output)
(png-from-file (coloring-axis-plot "images/coloring-axis-plot.png"))
COLORING-AXIS-PLOT
SB-INT:SIMPLE-STYLE-WARNING: The variable S is defined but never used. SB-KERNEL:REDEFINITION-WITH-DEFUN: redefining COMMON-LISP-USER::COLORING-AXIS-PLOT in DEFUN
" set terminal pngcairo font \"times,8\" set output \"images/coloring-axis-plot.png\" set multiplot set tmargin at screen 0.8 set rmargin at screen 0.8 set lmargin at screen 0.2 set bmargin at screen 0.2 set tics nomirror set xrange [0:5] set border 8 set border lt 4 set y2tics 0,25,150 set y2label \"exp(x)\" textcolor lt 4 unset key unset ytics plot exp(x) axis x1y2 lt 4 plot 1/x lt -1 set border 7 set border lt -1 set ylabel \"1/x\" textcolor lt -1 unset y2label set ytics 0,1,5 set tics nomirror unset y2tics set yrange [0:5] unset y2tics unset multiplot set output"