emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] gnuplot: plotting students' progress of grades


From: John Kitchin
Subject: Re: [O] gnuplot: plotting students' progress of grades
Date: Tue, 01 Sep 2015 08:35:19 -0400

You can transpose the table like this:
(org-table-transpose-table-at-point)

Alternatively (adapted from that code): this might get you where you
need to be:

#+name: my-data
| 1 | 2 | 3 | 4 |
| a | b | c | d |

#+BEGIN_SRC emacs-lisp
(defun get-transposed-table (tblname)
  (save-excursion
    (org-open-link-from-string (format  "[[%s]]" tblname))
    (while (not (org-table-p))
      (forward-line))
    (let* ((table (delete 'hline (org-table-to-lisp)))
           (contents (mapcar (lambda (p)
                               (let ((tp table))
                                 (mapcar
                                  (lambda (rown)
                                    (prog1
                                        (pop (car tp))
                                      (setq tp (cdr tp))))
                                  table)))
                             (car table))))
      (mapconcat (lambda(x) (concat "| " (mapconcat 'identity x " | " ) "  |\n" 
))
                 contents ""))))
#+END_SRC

#+RESULTS:
: get-transposed-table

#+BEGIN_SRC python :var data=(get-transposed-table "my-data")
print data
#+END_SRC

#+RESULTS:
: | 1 | a  |
: | 2 | b  |
: | 3 | c  |
: | 4 | d  |
:




Eric S Fraga writes:

> On Tuesday,  1 Sep 2015 at 08:38, Robert Klein wrote:
>
> [...]
>
>> You can use something like this:
>
> [...]
>
>> #+begin_src gnuplot :var data=grades :file noten.png
>>   put your gnuplot code here
>> #+end_src
>
> The problem for the OP will be that the data are in rows instead of
> columns and gnuplot will only plot columns (selected using
> "using").  The table needs to be transposed first (which is possible but
> don't ask me how ;-).

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]