pythonlatexformula

How to render Latex markup using Python?


How to show an easy latex-formula in python? Maybe numpy is the right choice?

I have python code like:

a = '\frac{a}{b}'

and want to print this in a graphical output (like matplotlib).


Solution

  • As suggested by Andrew little work around using matplotlib.

    import matplotlib.pyplot as plt
    a = '\\frac{a}{b}'  #notice escaped slash
    plt.plot()
    plt.text(0.5, 0.5,'$%s$'%a)
    plt.show()