Here's the example I had in mind:
* Example
#+name: example_plot
#+begin_src python :exports none
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure(figsize = (3, 2))
plt.plot([1, 3, 2])
fig.tight_layout()
plt.savefig('myfig.pdf')
'myfig.pdf'
#+end_src
* Example output
#+caption: This is an example plot
#+label: example-label
call_example_plot[:session]()[:results file :exports results]
Exported to LaTeX it produces:
% Created 2015-05-05 Tue 18:53
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage[utf8]{inputenc}
\author{wvxvw}
\date{\today}
\title{test-plot}
\hypersetup{
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 25.0.50.1 (Org mode 8.2.2)}}
\begin{document}
\maketitle
\tableofcontents
\section{Example}
\label{sec-1}
\section{Example output}
\label{sec-2}
\begin{figure}[htb]
\centering
\includegraphics[width=.9\linewidth]{myfig.pdf}
\caption{\label{example-label}This is an example plot}
\end{figure}
% Emacs 25.0.50.1 (Org mode 8.2.2)
\end{document}
#+name: generate_image
for example, then use#+caption: image caption
and on the next line#+call: generate_image
. I think you will also need to place the Babel source block headers in the#+call:
line instead of the original block (and make the original output nothing via#+header: results none
). – wvxvw May 5 '15 at 13:41#+results
, I didn't think of it. Anyways, I'm going to add an example, just for the sake of diversity. – wvxvw May 5 '15 at 15:19