2018-01-18 08:09:39 +00:00
|
|
|
from io import BytesIO
|
2018-01-18 09:47:45 +00:00
|
|
|
import matplotlib.pyplot as plt
|
2018-01-18 08:09:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_png(tex):
|
|
|
|
buf = BytesIO()
|
|
|
|
|
2018-01-18 09:47:45 +00:00
|
|
|
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)
|
2018-01-18 08:09:39 +00:00
|
|
|
|
2018-01-18 09:47:45 +00:00
|
|
|
plt.savefig(buf)
|
2018-01-18 08:09:39 +00:00
|
|
|
|
|
|
|
buf.seek(0)
|
|
|
|
|
|
|
|
|
|
|
|
return buf
|
2018-01-18 09:47:45 +00:00
|
|
|
|