Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to quickly plot elisp functions with gnuplot?

Tags:

gnuplot

elisp

Is there an emacs-lisp command which I could use to plot a collection of numbers with gnuplot, much like I can create simple line charts in Excel from an array of numbers?

For example, I would like to have a function called something like plot-with-gnuplot which I could call with something like:

(plot-with-gnuplot '((0 0.1) (0.1 1) (0.5 10)))

and have this produce a simple line plot going through those points.

Ultimately I will be using this to view mathematical functions that I am writing, it would be useful to be able to have a quick look at how my code is coming along by drawing a simple line plot of its values over a certain range.

like image 425
Robert Avatar asked Sep 08 '25 06:09

Robert


1 Answers

It is not exactly what you want but you may find Org-babel-gnuplot from org-mode useful. I've made an example file, it should work if you have gnuplot.el and emacs24. Run the first code block (C-c C-c), and then run the third code block.

test.org:

#+BEGIN_SRC emacs-lisp :results silent
;; load gnuplot mode
(require 'gnuplot "~/Dropbox/emacs/gnuplot.el")
(require 'ob-gnuplot)
#+END_SRC

#+NAME: edata
#+BEGIN_SRC emacs-lisp
'((0 0.1) (0.1 1) (0.5 10)))
#+END_SRC

#+BEGIN_SRC gnuplot :file file.png :var data=edata
plot data w lp
#+END_SRC

snapshot

like image 79
slitvinov Avatar answered Sep 11 '25 01:09

slitvinov