Is it possible to create a function image tag in html from a BytesIO buffer? I would like to do something in this direction:
import matplotlib matplotlib.use('Agg') import pylab import Image import io temp_data = {'x':[1,2,3],'y':[2,4,5]} pylab.plot(temp_data['x'], temp_data['y']) img_buffer = io.BytesIO() pylab.savefig(img_buffer, format = 'png') img_buffer.seek(0) img_tag = "<img src='data:image/png;base64,'" + img_buffer.getvalue() + "</img>"
You may need to reformat the buffer value in some way or modify the contents of the 'src' data. Thanks.
source share