From mboxrd@z Thu Jan 1 00:00:00 1970 From: Georgiy Tugai Subject: Re: Add caption to babel-generated images Date: Tue, 30 Aug 2016 20:34:10 +0930 Message-ID: <20160830110410.GA19154@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HcAYCG3uE/tztfnV" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1begq7-0001tc-DC for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1begq1-0008Re-2i for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:04:22 -0400 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]:35416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1begq0-0008RS-Qz for emacs-orgmode@gnu.org; Tue, 30 Aug 2016 07:04:17 -0400 Received: by mail-pf0-x232.google.com with SMTP id x72so6987384pfd.2 for ; Tue, 30 Aug 2016 04:04:16 -0700 (PDT) Received: from gmail.com ([101.166.208.194]) by smtp.googlemail.com with ESMTPSA id m128sm56214289pfm.42.2016.08.30.04.04.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Aug 2016 04:04:14 -0700 (PDT) Content-Disposition: inline In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I don't know if it'll work for Python, but here's an example of what works for me with Ditaa: > #+BEGIN_SRC ditaa :file figs/-mininet-ovsk.png :cache yes > /----+ /----+ /----+ /----+ > |host| |host| |host| |host| Containers > +-+--/ +-+--/ +--+-/ +--+-/ > | | | | > --------------------------------------------- > | | | | > +-+------+-------+------+-+ > | Open VSwitch | Host kernel > +-----+-------------+---=3D-+ > | | > +------+-----+ +-----+------+ > | controller | | controller | Host userspace > +------------+ +------------+ > #+END_SRC >=20 > #+ATTR_LATEX: :width "" :options [scale=3D0.75] > #+CAPTION: [[label:fig:mininet-arch]]Mininet with OpenVSwitch architecture > #+RESULTS[1d367d39f18523f4eb247cb13aabd6c6f633fbdf]: [[file:figs/-mininet= -ovsk.png]] First, execute your Babel block in order to generate a #+RESULTS line. Then, add CAPTION, ATTR_LATEX etc. lines before the RESULTS line. Good luck! Georgiy On 30 Aug, Florian Lindner wrote: > Hello, >=20 > I have this code block: >=20 > #+BEGIN_SRC python :exports results :results file > import matplotlib.pyplot as plt, numpy as np > x =3D np.linspace(-2, 2, 1000) > plt.plot(x, np.exp(-np.power(4*x, 2)), label=3D"shape-parameter=3D4") > for i in range(-4, 5): plt.axvline(1/6 * i, ymax =3D 0.1, ls =3D "-.", = color=3D"r") > plt.grid() > plt.savefig('rbf-gaussian-4.pdf') > return "rbf-gaussian-4.pdf" > #+END_SRC >=20 > When exporting to latex it nicely compiles into \includegraphics[width=3D= =2E9\linewidth]{rbf-gaussian-4.pdf}. >=20 > Now I want to have this \includegraphics in a figure environement includi= ng a label (to reference it) and a caption. >=20 > How can do this best? >=20 > I have found: > http://emacs.stackexchange.com/questions/12150/add-caption-to-an-image-ge= nerated-by-a-code-block >=20 > but it doesn't work for me. >=20 > Thanks, > Florian >=20 >=20 --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJXxWgqAAoJEFTCINVvWbOZkNkH/RwHTIhLBD8A3OjnO9WbfMG9 Gu9Cc9MtljY1XxEg8TjIfqFMfMqE3N5MyCVv1iT+ow+zchKZBQmWaMqtfBNim2yx Tc5IFT5L9n0BCJE8S3iId0yFHvB77UZFMR8xcsluyshpV9xoa/OIdXZfJ1Lf52a0 G0pVmzlzyA0NOU8FwUlUnOLnb7FTY7hok+K7rU8hXyECEgECGCYbka11e2vGULHm rSZouXpiu5AdVm6vpUocLlavJfw/AXZvI+osPuh2fCqlBsgkFENiQcoxAX/Wx8zd R4MZK9SGdhZ+90EfM4BRlT8speA61YDPAtg+DxXmpxGKKFtdQuPK8RSbri9L7w0= =GzP5 -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV--