从jupyter笔记本内部,有没有办法在每个内联matplotlib图下方添加乳胶图标题?这是期望的,以便在运行nbconvert时使用每个图形注释 - 到乳胶。
但我不清楚如何将LaTeX相对于最终位于\ begin {verbatim}块中的数字定位。我可以把它放在情节之后的降价格中;但是,这并不是我想要的数字。
答案 0 :(得分:1)
您可以按照Julius Schulz先生在Making Publication Ready Notebooks博客文章中的示例添加字幕。该技术基本上归结为将标题添加为生成图形的单元格的JSON元数据的一部分,然后在传递给nbconvert的模板中提供正确的指令。我直接复制粘贴了Julius'模板文件绘制数字,因为我在Jinja模板前面不太热。这篇博文对我很有帮助。
答案 1 :(得分:0)
一些解决方法,但是下面的辅助函数调用plt.close()来保持显示内联数字,只留下生成的LaTeX块。
bShowInline = True # Set = False for 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))
有更清洁的方式吗?