瀏覽代碼

gnuplot: switching to using user defined variables for handling variables

This will require gnuplot version 4.2 or up
Eric Schulte 16 年之前
父節點
當前提交
9bdddde454
共有 2 個文件被更改,包括 12 次插入9 次删除
  1. 7 6
      lisp/langs/org-babel-gnuplot.el
  2. 5 3
      org-babel.org

+ 7 - 6
lisp/langs/org-babel-gnuplot.el

@@ -77,12 +77,13 @@ called by `org-babel-execute-src-block'."
 	 (y-labels (plist-get params :ylabels))
 	 (time-ind (plist-get params :timeind)))
     ;; insert variables into code body
-    (mapc
-     (lambda (pair)
-       (setq body
-             (replace-regexp-in-string
-              (regexp-quote (format "%s" (car pair))) (cdr pair) body)))
-     vars)
+    (setq body
+          (concat
+           (mapconcat
+            (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair)))
+            vars "\n")
+           "\n"
+           body))
     ;; append header argument settings to body
     (when title (add-to-script (format "set title '%s'" title))) ;; title
     (when lines (mapc (lambda (el) (add-to-script el)) lines)) ;; line

+ 5 - 3
org-babel.org

@@ -2119,12 +2119,14 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip
 #+srcname: implementing-gnuplot
 #+begin_src gnuplot :var data=gnuplot-data
 set title "Implementing Gnuplot"
-plot "data" using 1:2 with lines
+plot data using 1:2 with lines
 #+end_src
 
-
-
 **** DONE add variables
+     gnuplot 4.2 and up support user defined variables.  This is how
+     we will handle variables with org-babel (meaning we will need to
+     require gnuplot 4.2 and up for variable support).
+
      - scalar variables should be replaced in the body of the gnuplot code
      - vector variables should be exported to tab-separated files, and
        the variable names should be replaced with the path to the files