This eepitch was included in Edrxās eev knowledge collection!
(require "asdf")
(asdf:load-system :screwlisps-knowledge/simple-gnuplot)
(use-package :screwlisps-knowledge/simple-gnuplot)
(gnuplot "Of these" '((-1 2) (1 2)) '((3 4) (4 4)) '((-1 2) (4 4)))
https://codeberg.org/tfw/screwlisps-knowledge/src/branch/main/simple-gnuplot.lisp
Congealing my earlier article on common lisp gnuplot into our new systematic package approach. Bear with me and feedback on your experience of the useage via the mastodon if you have time.
eev
style is to be transparent if not necessarily unsubtle. So
(eepitch-shell)
sudo apt install gnuplot
mkdir -p ~/gits
mkdir -p ~/common-lisp
cd ~/gits
git clone ssh://git@codeberg.org/tfw/screwlisps-knowledge.git
cd ~/common-lisp
ln -s ~/gits/screwlisps-knowledge
cd ~/common-lisp/screwlisps-knowledge
touch simple-gnuplot.lisp
hmmm Iām probably going to regret deciding to use a flat directory structure to ensure uniformity and lack of name collisions.
my intent with simple-gnuplot
is to reduce a great swathe of common graph plotting in lisp to (apply 'gnuplot "my good title" list more-lists)
(or (gnuplot 'title ((1 2) (3 4)) ((5 6) (7 8)))
if you prefer). The apply
form is useful if you have a list of lists you want to plot, but have one or two more lists to optionally add in the middle, similar to the :keyword
appy
idiom.
~/common-lisp/screwlisps-knowledge/simple-gnuplot.lisp
Definition(uiop:define-package :screwlisps-knowledge/simple-gnuplot
(:mix :asdf :cl)
(:export #:gnuplot))
(in-package :screwlisps-knowledge/simple-gnuplot)
(defun gnuplot (title &rest x-y-lists)
(let ((cmd (format
nil
"gnuplot -p -e \"~
set title '~a'; ~
unset key; ~
unset xtics; ~
set xrange [~,1f:~,1f]; ~
set yrange [~,1f:~,1f]; ~
plot ~{~1*'-' using 1:2 with lines~^,~^ ~};~
\""
title
(apply 'min (mapcar 'car (apply 'append x-y-lists)))
(apply 'max (mapcar 'car (apply 'append x-y-lists)))
(apply 'min (mapcar 'cadr (apply 'append x-y-lists)))
(apply 'max (mapcar 'cadr (apply 'append x-y-lists)))
x-y-lists)))
(with-input-from-string
(in (format nil "~{~{~{~,1f ~,1f~}~%~}e~^~%~}" x-y-lists))
(uiop:run-program cmd :input in))))
(setf (documentation 'gnuplot 'function)
"gnuplot (title &rest lists)
title: Probably a string or symbol describing the otherwise terse graph plot(s).
lists: any number of lists like ((1 2) (3 4) (5 6)) ((7 8) (9 10)) ((11 12)) being (x y) pairs.
invokes gnuplot with lines on all of the lists.")
and we have to add it to ~/gits/screwlisps-knowledge/all.lisp
as well actually, I guess there is no free lunch.
(require "asdf")
(asdf:load-system :screwlisps-knowledge/simple-gnuplot)
(use-package :screwlisps-knowledge/simple-gnuplot)
(gnuplot "foo bar" '((-1 2) (1 2)) '((3 4) (4 4)) '((-1 2) (4 4)))
Well, it works and I think this works. I am interested in hearing about how easy it was for you to personally use probably on this Mastodon thread. Show will be live 000UTC Wednesday as every week, watch the Mastodon.
screwlisp proposes kittens