Jelajahi Sumber

Plotting: Fix histogram plotting.

William Henney writes:

     The following table works correctly with org-plot
    #+PLOT: title:"org-plot test" ind:1 type:2d with:hist set:"style fill
    solid" set:"yrange [0:]"
     |  Year | a | b |
     |-------+---+---|
     | x2006 | 3 | 1 |
     |  2007 | 1 | 2 |
     |  2008 | 2 | 0 |

     However, if the "x" is removed from the start of all the years, it no
     longer works:

    #+PLOT: title:"org-plot bug" ind:1 type:2d with:hist set:"style fill
    solid" set:"yrange [0:]"
     | Year | a | b |
     |------+---+---|
     | 2006 | 3 | 1 |
     | 2007 | 1 | 2 |
     | 2008 | 2 | 0 |

     From glancing through org-plot.el, it seems as though the problem is
     that the text-ind parameter is false when all the values in the
     "independent variable" column are legal numbers. However, my lisp
     skills are not up to fixing this.

This patch is by Charles Sebold and Eric Schulte fixes the problem.
Carsten Dominik 16 tahun lalu
induk
melakukan
1edd9d0cc6
2 mengubah file dengan 11 tambahan dan 6 penghapusan
  1. 3 0
      lisp/ChangeLog
  2. 8 6
      lisp/org-plot.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-01-16  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-plot.el (org-plot/gnuplot): Fix text-ind parameter for
+	histograms.
+
 	* org-colview.el (org-colview-construct-allowed-dates): Better
 	error catching when a date/time property does not have allowed
 	values defined.

+ 8 - 6
lisp/org-plot.el

@@ -316,12 +316,14 @@ line directly before or after the table."
 			   (mapcar (lambda (row) (nth ind row)) table)))) 0)
 	      (plist-put params :timeind t)
 	    ;; check for text ind column
-	    (if (> (length
-		    (delq 0 (mapcar
-			     (lambda (el)
-			       (if (string-match org-table-number-regexp el)
-				   0 1))
-			     (mapcar (lambda (row) (nth ind row)) table)))) 0)
+
+	    (if (or (string= (plist-get params :with) "hist")
+		    (> (length
+			(delq 0 (mapcar
+				 (lambda (el)
+				   (if (string-match org-table-number-regexp el)
+				       0 1))
+				 (mapcar (lambda (row) (nth ind row)) table)))) 0))
 		(plist-put params :textind t)))))
       ;; write script
       (with-temp-buffer