emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] python/babel inline images


From: Eric Schulte
Subject: Re: [O] python/babel inline images
Date: Tue, 05 Jun 2012 08:57:19 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.97 (gnu/linux)

henry atting <address@hidden> writes:

> Hi,
>
> I do not succeed in generating an inline image as a result of a
> python code block. The code itself works, C-c C-c generates the
> according picture, but only in my home directory. The code block:
>
> -*- org-babel-python-command: "python3" -*-
> #+begin_src python
> import csv
> import matplotlib.pyplot as plot
> x = []
> y = []
> csv_reader = csv.reader(open('csv_data.csv'))
> for line in csv_reader:
>       x.append(int(line[0]))
>       y.append(float(line[1]))
> plot.plot(x, y, label=r'exp', color='green')
> plot.legend(loc='lower right')
> plot.savefig("exp_csv.svg")
> #+end_src
>
> It tried different combinations of `:exports results', `:results
> file', `:file filename'

I'm not python expert, but the code block should be run in your current
directory, e.g., the following outputs the current working path expected
for me.

#+begin_src sh
  pwd
#+end_src

If you want to explicitly pass the current directory to your code block
as an argument, you could try something like the following

#+begin_src python :var mydir=(file-name-directory (buffer-file-name))
  return mydir
#+end_src

Hope this helps,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte



reply via email to

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