Browse Source

Make plotting work for tables starting with hline.

Carsten Dominik 16 years ago
parent
commit
a7febf233e
2 changed files with 14 additions and 6 deletions
  1. 7 0
      lisp/ChangeLog
  2. 7 6
      lisp/org-plot.el

+ 7 - 0
lisp/ChangeLog

@@ -1,3 +1,10 @@
+2008-09-22  James TA Smith  <ahktenzero@mohorovi.cc>
+
+	* org-plot.el (org-plot/gnuplot): Make tables starting with a
+	hline work correctly.
+	(org-plot/gnuplot-script): Put commas at the end of each script
+	line.
+
 2008-09-20  James TD Smith  <ahktenzero@mohorovi.cc>
 2008-09-20  James TD Smith  <ahktenzero@mohorovi.cc>
 
 
 	* org.el (org-get-refile-targets): Replace links with their
 	* org.el (org-get-refile-targets): Replace links with their

+ 7 - 6
lisp/org-plot.el

@@ -218,7 +218,7 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
 			      (format "\"%s\" %d" (cdr pair) (car pair)))
 			      (format "\"%s\" %d" (cdr pair) (car pair)))
 			    y-labels ", "))))
 			    y-labels ", "))))
       (case type ;; plot command
       (case type ;; plot command
-	('2d (dotimes (col num-cols) 
+	('2d (dotimes (col num-cols)
 	       (unless (and (equal type '2d)
 	       (unless (and (equal type '2d)
 			    (or (and ind (equal (+ 1 col) ind))
 			    (or (and ind (equal (+ 1 col) ind))
 				(and deps (not (member (+ 1 col) deps)))))
 				(and deps (not (member (+ 1 col) deps)))))
@@ -239,11 +239,11 @@ NUM-COLS controls the number of columns plotted in a 2-d plot."
 	 (setq plot-lines (list (format "'%s' with %s title ''"
 	 (setq plot-lines (list (format "'%s' with %s title ''"
 					data-file with)))))
 					data-file with)))))
       (add-to-script
       (add-to-script
-       (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) "\\\n    ,")))
+       (concat plot-cmd " " (mapconcat 'identity (reverse plot-lines) ",\\\n    ")))
       script)))
       script)))
 
 
 ;;-----------------------------------------------------------------------------
 ;;-----------------------------------------------------------------------------
-;; facad functions
+;; facade functions
 ;;;###autoload
 ;;;###autoload
 (defun org-plot/gnuplot (&optional params)
 (defun org-plot/gnuplot (&optional params)
   "Plot table using gnuplot. Gnuplot options can be specified with PARAMS.
   "Plot table using gnuplot. Gnuplot options can be specified with PARAMS.
@@ -255,11 +255,11 @@ line directly before or after the table."
     (delete-other-windows)
     (delete-other-windows)
     (when (get-buffer "*gnuplot*") ;; reset *gnuplot* if it already running
     (when (get-buffer "*gnuplot*") ;; reset *gnuplot* if it already running
       (save-excursion
       (save-excursion
-	(set-buffer "*gnuplot*") (goto-char (point-max)) 
+	(set-buffer "*gnuplot*") (goto-char (point-max))
 	(gnuplot-delchar-or-maybe-eof nil)))
 	(gnuplot-delchar-or-maybe-eof nil)))
     (org-plot/goto-nearest-table)
     (org-plot/goto-nearest-table)
     ;; set default options
     ;; set default options
-    (mapc 
+    (mapc
      (lambda (pair)
      (lambda (pair)
        (unless (plist-member params (car pair))
        (unless (plist-member params (car pair))
 	 (setf params (plist-put params (car pair) (cdr pair)))))
 	 (setf params (plist-put params (car pair) (cdr pair)))))
@@ -267,7 +267,8 @@ line directly before or after the table."
     ;; collect table and table information
     ;; collect table and table information
     (let* ((data-file (make-temp-file "org-plot"))
     (let* ((data-file (make-temp-file "org-plot"))
 	   (table (org-table-to-lisp))
 	   (table (org-table-to-lisp))
-	   (num-cols (length (first table))))
+	   (num-cols (length (if (eq (first table) 'hline) (second table)
+			       (first table)))))
       (while (equal 'hline (first table)) (setf table (cdr table)))
       (while (equal 'hline (first table)) (setf table (cdr table)))
       (when (equal (second table) 'hline)
       (when (equal (second table) 'hline)
 	(setf params (plist-put params :labels (first table))) ;; headers to labels
 	(setf params (plist-put params :labels (first table))) ;; headers to labels