From: edgar@openmail.cc
To: emacs-orgmode@gnu.org
Subject: How to call nested bash and gnuplot with babel?
Date: Fri, 25 Aug 2017 03:26:58 +0000 [thread overview]
Message-ID: <8df2f105af6682485733fe21a879feb4@openmail.cc> (raw)
Hello, I am trying to run a "nested" babel code with bash and gnuplot.
* Configuration
I did the test like this
#+BEGIN_SRC bash
emacs -Q
#+END_SRC
#+BEGIN_SRC emacs-lisp
(require 'package)
(package-initialize)
(require 'org)
;; Org mode version 9.0.9
(org-babel-do-load-languages ; babel, for executing
'org-babel-load-languages ; code in org-mode.
'((shell . t)
(python . t)
(emacs-lisp . t)
(org . t)
(gnuplot . t)))
#+END_SRC
* Original code
#+NAME: bash-tjp-displ-stress
#+HEADER: :var file1="file1.csv"
#+HEADER: :var col1="3"
#+HEADER: :var file2="file2.csv"
#+HEADER: :var col2="7"
#+HEADER: :dir "Data"
#+BEGIN_SRC bash :results value :exports code
paste "$file1" "$file2" | awk -F',' '/^[^#]/{print $'$col1' $'$col2'}'
#+END_SRC
#+NAME: gplt-tjp-febio-results
#+CAPTION: Gnuplot to plot
#+HEADER: :var data=bash-tjp-displ-stress
#+BEGIN_SRC gnuplot :results graphics :file /tmp/orig-out.png
set xlabel 'var1'
set ylabel 'var2'
plot data u ($1 + 1):2 with lp notitle
#+END_SRC
** Alternative 1: ~:file~ after the function
The result of this gives me the original output file
#+CALL: gplt-tjp-febio-results() :file /tmp/test.png
#+RESULTS:
[[file:/tmp/orig-out.png]]
** Alternative 2: ~:file~ as a prefix to the function
The result of this gives me the original output file
#+CALL: gplt-tjp-febio-results[:file /tmp/test.png]()
#+RESULTS:
[[file:/tmp/orig-out.png]]
* Modified code
If I do this, I get the desired output file (add variable ~outfile~
and ~:results none~)
#+NAME: gplt-tjp-febio-results-new
#+CAPTION: Gnuplot to plot
#+HEADER: :var data=bash-tjp-displ-stress
#+HEADER: :var outfile="/tmp/test.png"
#+BEGIN_SRC gnuplot :results graphics
set output outfile
set xlabel 'var1'
set ylabel 'var2'
plot data u ($1 + 1):2 with lp notitle
#+END_SRC
#+CALL: gplt-tjp-febio-results-new[:results
none](outfile="/tmp/new_out.png")
I type this manually:
[[/tmp/new_out.png]]
* What I expected
To call
#+BEGIN_EXAMPLE
,#+CALL: gplt-tjp-febio-results() :file /tmp/new_out.png
#+END_EXAMPLE
and get
#+BEGIN_EXAMPLE
,#+RESULTS:
[[file:/tmp/orig-out.png]]
#+END_EXAMPLE
How do I achieve this?
* Thanks
Thank you! :D
-------------------------------------------------
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!
reply other threads:[~2017-08-25 16:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=8df2f105af6682485733fe21a879feb4@openmail.cc \
--to=edgar@openmail.cc \
--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).