fixed a bug with wrong LaTeX input

This commit is contained in:
Daniel Knuettel 2018-02-03 18:31:47 +01:00
parent 249e64bc72
commit 6095292560

View File

@ -20,21 +20,34 @@ from io import BytesIO
import matplotlib import matplotlib
matplotlib.use("Agg") matplotlib.use("Agg")
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import importlib
def get_png(tex): def get_png(tex):
importlib.reload(plt)
buf = BytesIO() buf = BytesIO()
plt.text(0, 0.6, r"$%s$" % tex, fontsize = 50) exc = None
fig = plt.gca()
fig.axes.get_xaxis().set_visible(False)
fig.axes.get_yaxis().set_visible(False)
plt.savefig(buf) try:
plt.subplot()
buf.seek(0) plt.text(0, 0.6, r"$%s$" % tex, fontsize = 50)
fig = plt.gca()
fig.axes.get_xaxis().set_visible(False)
fig.axes.get_yaxis().set_visible(False)
plt.clf() plt.savefig(buf)
buf.seek(0)
except Exception as e:
exc = e
finally:
plt.clf()
if(exc):
raise exc
return buf return buf