1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-22 07:09:47 +00:00

org-plot.el: add new custom gnuplot preamble

* lisp/org-plot.el (org-plot/gnuplot-script-preamble): New option
which can be either a string or a function.  The value of this (when
executed, in the case of the function) is inserted near the top of the
generated gnuplot script.
(org-plot/gnuplot-script): Use the new variable
`org-plot/gnuplot-script-preamble' in the manner described.

This allows for the user to set the font/colour-scheme, default
precision, and much more.
This commit is contained in:
TEC 2020-07-08 22:26:21 +08:00 committed by Bastien
parent 8d5122fc5e
commit a1d92bd918

View File

@ -182,6 +182,13 @@ and dependent variables."
(setf back-edge "") (setf front-edge ""))))
row-vals))
(defcustom org-plot/gnuplot-script-preamble ""
"String or function which provides content to be inserted into the GNUPlot
script before the plot command. Not that this is in addition to, not instead of
other content generated in `org-plot/gnuplot-script'."
:group 'org-plot
:type '(choice string function))
(defun org-plot/gnuplot-script (data-file num-cols params &optional preface)
"Write a gnuplot script to DATA-FILE respecting the options set in PARAMS.
NUM-COLS controls the number of columns plotted in a 2-d plot.
@ -214,6 +221,12 @@ manner suitable for prepending to a user-specified script."
(when file ; output file
(funcall ats (format "set term %s" (file-name-extension file)))
(funcall ats (format "set output '%s'" file)))
(funcall ats
(if (stringp org-plot/gnuplot-script-preamble)
org-plot/gnuplot-script-preamble
(org-plot/gnuplot-script-preamble)))
(pcase type ; type
(`2d ())
(`3d (when map (funcall ats "set map")))