This question has been asked in a similar way here but the answer was way over my head (I\'m super new to python and web development) so I\'m hoping there\'s a simpler way o
what works for me with python3 is:
buf = io.BytesIO() plt.savefig(buf, format='png') image_base64 = base64.b64encode(buf.getvalue()).decode('utf-8').replace('\n', '') buf.close()