From: Pierre de Buyl <pdebuyl@ulb.ac.be>
To: Torsten Bronger <bronger@physik.rwth-aachen.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Matplotlib (Python) plots inline
Date: Mon, 6 Jun 2011 08:09:18 -0400 [thread overview]
Message-ID: <A791019D-3F1D-40D3-953C-BD163E5B781C@ulb.ac.be> (raw)
In-Reply-To: <87fwnn71t9.fsf@physik.rwth-aachen.de>
Hello,
I have success with the following:
#+begin_src python :results output raw :exports results
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()
print "[[/tmp/plot_test.png]]"
#+end_src
You get only the figure as a result, and not the code.
This method executes the code at each export. The alternative is to
set ":exports none" , to execute with C-c C-c and then to delete the
"+results:" line so that the result is exported.
Pierre
Le 6 juin 11 à 05:21, Torsten Bronger a écrit :
> 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
>
> --8<---------------cut here---------------start------------->8---
> #+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]]
> --8<---------------cut here---------------end--------------->8---
>
> 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.
>
> --
> Torsten Bronger Jabber ID: torsten.bronger@jabber.rwth-aachen.de
> or http://bronger-jmp.appspot.com
>
>
next prev parent reply other threads:[~2011-06-06 12:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 9:21 Matplotlib (Python) plots inline Torsten Bronger
2011-06-06 12:09 ` Pierre de Buyl [this message]
2011-06-09 7:30 ` Torsten Bronger
2011-06-06 12:14 ` Eric Schulte
2011-06-09 7:29 ` Torsten Bronger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=A791019D-3F1D-40D3-953C-BD163E5B781C@ulb.ac.be \
--to=pdebuyl@ulb.ac.be \
--cc=bronger@physik.rwth-aachen.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).