From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [babel] how to pass data to gnuplot from another block Date: Fri, 22 Nov 2013 12:27:50 -0500 Message-ID: <8738mol52h.fsf@alphaville.bos.redhat.com> References: <87d2lsbvy7.fsf@ucl.ac.uk> <87iovkihe6.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjuWc-0001w1-C3 for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 12:28:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjuWV-0004xV-0q for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 12:28:14 -0500 Received: from plane.gmane.org ([80.91.229.3]:52399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjuWU-0004xR-Pg for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 12:28:06 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VjuWQ-0006vu-98 for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 18:28:02 +0100 Received: from nat-pool-bos-t.redhat.com ([66.187.233.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Nov 2013 18:28:02 +0100 Received: from ndokos by nat-pool-bos-t.redhat.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 22 Nov 2013 18:28:02 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Eric Schulte writes: > The attached works fine for me (using sh since I don't have octave). > > #+name: uptime > #+begin_src sh > paste <(echo -e "1\n5\n15") <(uptime|sed 's/^.*average: //;s/,//g'|tr ' ' '\n') > #+end_src > Just an fyi: I had to set org-babel-sh-command to "bash" for this to work. Why is "sh" the default value of this variable? > #+RESULTS: uptime > | 1 | 0.02 | > | 5 | 0.06 | > | 15 | 0.05 | > > #+begin_src gnuplot :var data=uptime :results silent > set xrange [0:] > set yrange [0:] > set title "uptime" > set xlabel "minutes ago" > set ylabel "load" > plot data w lines > #+end_src > > Ensure that the data you're passing into gnuplot is a table and not a > string. Gnuplot blocks handle tables by writing them to a file, and > then replacing the variable with the file name. As I recall gnuplot > blocks assume string data already is a file name, so the variable is > replaced directly. > Ah, that explains everything! I also didn't have octave on this machine so I wrote a python block. Initially, I had --8<---------------cut here---------------start------------->8--- #+name: foo #+begin_src python x = ((1, 1), (2, 4), (3, 9)) return "\n".join(["|%d | %d |" % (y[0], y[1]) for y in x]) #+end_src #+RESULTS: foo | 1 | 1 | | 2 | 4 | | 3 | 9 | --8<---------------cut here---------------end--------------->8--- which looks like a table, but isn't: the gnuplot block was blowing up just like Eric F's. I replaced it with --8<---------------cut here---------------start------------->8--- #+name: foo #+begin_src python x = ((1, 1), (2, 4), (3, 9)) return x #+end_src #+RESULTS: foo | 1 | 1 | | 2 | 4 | | 3 | 9 | --8<---------------cut here---------------end--------------->8--- and everything is working. The only problem is that the results *look* the same, so it's hard to see what the type is. Nick