emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sharing variables between source blocks without session


From: Loris Bennett
Subject: Re: Sharing variables between source blocks without session
Date: Tue, 16 Mar 2021 10:16:38 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

"Loris Bennett" <loris.bennett@fu-berlin.de> 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 loris.bennett@fu-berlin.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]