emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Matplotlib (Python) plots inline


From: Eric Schulte
Subject: Re: [O] Matplotlib (Python) plots inline
Date: Mon, 06 Jun 2011 06:14:04 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi Torsten,

You could try

#+begin_src python :exports results :file /tmp/plot_test.png
  ...
#+end_src

Which should behave as desired.

Best -- Eric

Torsten Bronger <address@hidden> writes:

> Hallöchen!
>
> I wonder what is the best way to include plots generated from Python
> code into my notes.  I found a way but maybe there's a better one.
>
> What I do is
>
> #+begin_src python
>   import numpy, matplotlib, matplotlib.pyplot
>   figure = matplotlib.pyplot.figure()
>   axes = figure.add_subplot(111, title=u"Hello", xlabel="x", ylabel="y")
>   x = numpy.arange(-10, 10, 0.1)
>   axes.plot(x, x**2)
>   figure.savefig("/tmp/plot_test.png")
>   figure.clf()
> #+end_src
>
> #+results:
> : None
>
> [[/tmp/plot_test.png]]
>
> However, it is a little bit cumbersome.  Is there an easier way to
> define code (possibly with boilerplate), and let it be replaced with
> the graphics file it produces?
>
> Tschö,
> Torsten.

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



reply via email to

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