[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sharing variables between source blocks without session
From: |
Loris Bennett |
Subject: |
Sharing variables between source blocks without session |
Date: |
Tue, 16 Mar 2021 09:56:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
Hi,
I have a 'sh' source block which produces a table which I then want to
plot with a 'python' source block:
#+NAME: code;raw_data
#+HEADER: :var user="loris"
#+BEGIN_SRC sh
ps -u loris -o etimes=
#+END_SRC
#+NAME: tab;raw_data
#+RESULTS: code;raw_data...
#+HEADER: :var df=tab;raw_data
#+HEADER: :var user="loris"
#+BEGIN_SRC python :results file :var f="process_times.pdf"
import numpy as np
import matplotlib.pyplot as plt
# flatten list
x = [item for sublist in df for item in sublist]
plt.hist(x, bins=10)
plt.xlabel("time [s]")
plt.ylabel("number of processes")
plt.title("user: " + user)
plt.savefig(f)
return f
#+END_SRC
How can I avoid having to declare the variable 'user' for both blocks?
Cheers,
Loris
--
This signature is currently under construction.
- Sharing variables between source blocks without session,
Loris Bennett <=
- Re: Sharing variables between source blocks without session, Loris Bennett, 2021/03/16
- Re: Sharing variables between source blocks without session, Eric S Fraga, 2021/03/16
- Re: Sharing variables between source blocks without session, Loris Bennett, 2021/03/18
- RE: Sharing variables between source blocks without session, Cook, Malcolm, 2021/03/18
- Re: Sharing variables between source blocks without session, Loris Bennett, 2021/03/19
- Re: Sharing variables between source blocks without session, Loris Bennett, 2021/03/19
- Re: Sharing variables between source blocks without session, Eric S Fraga, 2021/03/19
- Re: Sharing variables between source blocks without session, Loris Bennett, 2021/03/19