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 > +-----+-------------+---=-+ > | | > +------+-----+ +-----+------+ > | controller | | controller | Host userspace > +------------+ +------------+ > #+END_SRC > > #+ATTR_LATEX: :width "" :options [scale=0.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, > > I have this code block: > > #+BEGIN_SRC python :exports results :results file > import matplotlib.pyplot as plt, numpy as np > x = np.linspace(-2, 2, 1000) > plt.plot(x, np.exp(-np.power(4*x, 2)), label="shape-parameter=4") > for i in range(-4, 5): plt.axvline(1/6 * i, ymax = 0.1, ls = "-.", color="r") > plt.grid() > plt.savefig('rbf-gaussian-4.pdf') > return "rbf-gaussian-4.pdf" > #+END_SRC > > When exporting to latex it nicely compiles into \includegraphics[width=.9\linewidth]{rbf-gaussian-4.pdf}. > > Now I want to have this \includegraphics in a figure environement including a label (to reference it) and a caption. > > How can do this best? > > I have found: > http://emacs.stackexchange.com/questions/12150/add-caption-to-an-image-generated-by-a-code-block > > but it doesn't work for me. > > Thanks, > Florian > >