emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [babel] how to pass data to gnuplot from another block
Date: Fri, 22 Nov 2013 12:27:50 -0500	[thread overview]
Message-ID: <8738mol52h.fsf@alphaville.bos.redhat.com> (raw)
In-Reply-To: 87iovkihe6.fsf@gmail.com

Eric Schulte <schulte.eric@gmail.com> 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

  reply	other threads:[~2013-11-22 17:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22  9:57 [babel] how to pass data to gnuplot from another block Eric S Fraga
2013-11-22 15:00 ` Eric Schulte
2013-11-22 17:27   ` Nick Dokos [this message]
2013-11-23 16:15     ` Eric Schulte
2013-12-13 15:23       ` Greg Troxel
2013-12-13 15:30         ` Eric Schulte
2013-12-13 15:48           ` Greg Troxel
2013-12-13 16:20             ` Eric Schulte
2013-12-13 17:13               ` Eric Schulte
2013-12-13 19:32                 ` Nick Dokos
2013-12-13 22:40                 ` Achim Gratz
2013-12-13 23:18                 ` Eric Schulte
2013-12-14 10:21                   ` Achim Gratz
2013-12-13 18:38               ` Greg Troxel
2013-12-13 19:08                 ` Sebastien Vauban
2013-12-13 16:32           ` Achim Gratz
2013-12-05  7:35   ` Eric S Fraga
2013-12-05 18:29     ` Eric Schulte
2013-12-05 19:59       ` Eric S Fraga
2013-12-06  2:06         ` Eric Schulte
2013-12-06 11:59           ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738mol52h.fsf@alphaville.bos.redhat.com \
    --to=ndokos@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).