"Loris Bennett" <[email protected]> writes:
> 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
Oops, that should be
#+NAME: code;raw_data
#+HEADER: :var user="loris"
#+BEGIN_SRC sh
ps -u $user -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
--
Dr. Loris Bennett (Hr./Mr.)
ZEDAT, Freie Universität Berlin Email [email protected]