11 lines
251 B
Python
11 lines
251 B
Python
import base64
|
|
from io import BytesIO
|
|
import matplotlib
|
|
matplotlib.use("Agg")
|
|
|
|
def plot_to_base64(plt):
|
|
img = BytesIO()
|
|
plt.savefig(img, format="png", bbox_inches="tight")
|
|
img.seek(0)
|
|
return base64.b64encode(img.read()).decode("utf-8")
|