forked from mirrors/org-mode
org-plot.el: add new option :transpose
* lisp/org-plot.el (org-plot/add-options-to-plist, org-plot/add-options-to-plist): Add a new option :transpose, and a shorter alias :trans. Transposition is performed if the argument is yes, y, or t. This treats the table as a matrix and performs matrix transposition on it. If an hline is present, it is assumed that it is a marks a separation from a first header row. The first row is then treated as the new header by inserting a hline in the transposed data. This is quite useful for some plots, where across multiple categories, there are a large number of data points. Without this, the data points would be columns and the table can spread irritatingly wide.
This commit is contained in:
parent
a64aa25fa5
commit
8d5122fc5e
|
@ -63,7 +63,9 @@ Returns the resulting property list."
|
||||||
("labels" . :labels)
|
("labels" . :labels)
|
||||||
("map" . :map)
|
("map" . :map)
|
||||||
("timeind" . :timeind)
|
("timeind" . :timeind)
|
||||||
("timefmt" . :timefmt)))
|
("timefmt" . :timefmt)
|
||||||
|
("trans" . :transpose)
|
||||||
|
("transpose" . :transpose)))
|
||||||
(multiples '("set" "line"))
|
(multiples '("set" "line"))
|
||||||
(regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)")
|
(regexp ":\\([\"][^\"]+?[\"]\\|[(][^)]+?[)]\\|[^ \t\n\r;,.]*\\)")
|
||||||
(start 0))
|
(start 0))
|
||||||
|
@ -290,8 +292,20 @@ line directly before or after the table."
|
||||||
(setf params (plist-put params (car pair) (cdr pair)))))
|
(setf params (plist-put params (car pair) (cdr pair)))))
|
||||||
;; 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-collapse-header (org-table-to-lisp)))
|
(table (let ((tbl (org-table-to-lisp)))
|
||||||
(num-cols (length (car table))))
|
(when (pcase (plist-get params :transpose)
|
||||||
|
('y t)
|
||||||
|
('yes t)
|
||||||
|
('t t))
|
||||||
|
(if (memq 'hline tbl)
|
||||||
|
(setq tbl (apply #'cl-mapcar #'list tbl))
|
||||||
|
;; When present, remove hlines as they can't (currentily) be easily transposed.
|
||||||
|
(setq tbl (apply #'cl-mapcar #'list
|
||||||
|
(remove 'hline tbl)))
|
||||||
|
(push 'hline (cdr tbl))))
|
||||||
|
tbl))
|
||||||
|
(num-cols (length (if (eq (nth 0 table) 'hline) (nth 1 table)
|
||||||
|
(nth 0 table)))))
|
||||||
(run-with-idle-timer 0.1 nil #'delete-file data-file)
|
(run-with-idle-timer 0.1 nil #'delete-file data-file)
|
||||||
(when (eq (cadr table) 'hline)
|
(when (eq (cadr table) 'hline)
|
||||||
(setf params
|
(setf params
|
||||||
|
|
Loading…
Reference in a new issue