From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] how to pass data to gnuplot from another block Date: Fri, 22 Nov 2013 08:00:59 -0700 Message-ID: <87iovkihe6.fsf@gmail.com> References: <87d2lsbvy7.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjsh9-0005JF-UR for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 10:31:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vjsh3-0003K5-Vi for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 10:30:59 -0500 Received: from mail-pb0-x229.google.com ([2607:f8b0:400e:c01::229]:53615) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vjsh3-0003K0-NV for emacs-orgmode@gnu.org; Fri, 22 Nov 2013 10:30:53 -0500 Received: by mail-pb0-f41.google.com with SMTP id jt11so1452237pbb.14 for ; Fri, 22 Nov 2013 07:30:52 -0800 (PST) Received: from bagel (c-174-56-50-60.hsd1.nm.comcast.net. [174.56.50.60]) by mx.google.com with ESMTPSA id oj6sm60968461pab.9.2013.11.22.07.30.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2013 07:30:51 -0800 (PST) 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 --=-=-= Content-Type: text/plain Hi Eric, The attached works fine for me (using sh since I don't have octave). --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=sh-to-gnuplot.org #+name: uptime #+begin_src sh paste <(echo -e "1\n5\n15") <(uptime|sed 's/^.*average: //;s/,//g'|tr ' ' '\n') #+end_src #+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 --=-=-= Content-Type: text/plain 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. Best, Eric S Fraga writes: > Hello, > > everything I have seen on the list and on Worg seems to indicate that it > should be possible to pass data from a babel src block to a gnuplot src > block. See, for instance, the excellent article on data collection and > analysis at > > http://orgmode.org/worg/org-contrib/babel/examples/data-collection-analysis.html > > I don't have R so I have not tried the examples on this page. However, > I have tried the following using octave and gnuplot: > > #+begin_src org > ,#+TITLE: examplebug.org > ,#+AUTHOR: Eric S Fraga > ,* bubble and dew points > ,#+name: bubble-point-temperatures > ,#+begin_src octave :results raw output > A = [ 6.86880 6.84941]'; > B = [1154.646 1206.001]'; > C = [ 226.046 223.148]'; > pv = @(T) 10.^(A-B./(T+C)); > x = 0; > res = []; > while x<(1+1e-3) > f = @(T) 760 - [x (1-x)]*pv(T); > T = fsolve(f, 70); > printf("| %5.2f | %7.2f | \n", x, T); > res = [res; [x T] ]; > x = x + 0.05; > endwhile > ,#+end_src > > ,#+begin_src gnuplot :var data=bubble-point-temperatures :file "bubble.pdf" > set terminal pdfcairo mono enhanced font ",12" size 10cm,6cm > plot data > ,#+end_src > > ,#+results: > [[file:bubble.pdf]] > #+end_src > > Trying to execute the gnuplot block leads to an error in gnuplot because > the output of the octave data block is being put directly into the data > variable instead of into a file whose name is passed to the data > variable. The latter happens if the source of the data is a table > instead of a src block. > > I have tried various combinations of output directives for the first src > block but to no avail. > > I have tried this with "emacs -Q", by the way, and my org is up to date > as of a few minutes ago! > > What am I doing wrong please? > > Thanks, > eric -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D --=-=-=--