ipython notebook - How to add latex figure captions below jupyter / matplotlib figures -


from within jupyter notebook, there way add latex figure caption below each inline matplotlib figure? desired each figure annotated when running nbconvert --to latex.

but not clear on how position latex relative figure ends in \begin{verbatim} block. can place in markdown cell after plot; but, not wrap figure want.

a bit of workaround following helper function calls plt.close() keep inline figures being displayed leaving generated latex block figure.

bshowinline = true  # set = false document generation  def makeplot( plt, figlabel, figcaption):     figname = figlabel+'.png'      plt.savefig(figname)      if bshowinline:         plt.show()     else:         plt.close()      strlatex="""     \\begin{figure}[b]     \centering         \includegraphics[totalheight=10.0cm]{%s}         \caption{%s}         \label{fig:%s}     \end{figure}"""%(figname, figcaption, figlabel)      return display(latex(strlatex))  

is there cleaner way?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -