Forum Archive

Possible to implement LaTeX in Scene module?

zombie

Is there a way that I can get the Scene module to print a graphical LaTeX output, possibly as an image? My goal is to have Scene produce a few of these graphics so that they may be dragged around and have some interactivity. I have been exploring the SymPy and Matplotlib libraries, but it seems that both are concerned with printing to the console

I'm fairly new to both libraries, most of Python really.. I thought that I could possibly produce the graphic through Matplotlib, and have it available for Scene to draw, but I am struggling to execute such a approach. Thanks in advance!

Olaf

If you can draw the LaTeX string in matplotlib, there's a savefig function that saves the plot to a png file, which you could read and display in the Scene

JonB
import matplotlib.mathtext as mt
s=r'$\frac{A}{B} = C$'
mt.math_to_image(s, 'test.png')

the second argument to math_to_image could also be a BytesIO, etc.