How to add latex lettering under jupyter / matplotlib drawings

Inside a jupyter laptop, is there any way to add a latex signature under each matplotlib line drawing? It is advisable that each figure be annotated when you run nbconvert - in latex.

But I don’t understand how to position LaTeX relative to a figure that ends in the \ begin {verbatim} block. I can place it in the markdown cell immediately after the plot; but it does not wrap the figure as I want.

+4
source share
2 answers

A bit of a workaround, but the next helper function calls plt.close () to display inline shapes, leaving only the generated LaTeX block for the drawing.

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)) 

?

0

, " " - . JSON , , , nbconvert. Julius, , Jinja. .

+1

Source: https://habr.com/ru/post/1609543/


All Articles