New Matplotlib Demo Programs for PySimpleGUIWeb

This commit is contained in:
PySimpleGUI 2020-07-06 16:25:00 -04:00
parent 9435bb6393
commit 97061b3614
4 changed files with 78 additions and 14 deletions

View file

@ -846,16 +846,15 @@ def draw_figure(fig, element):
:param element: an Image Element
:return: The figure canvas
"""
plt.close('all')
plt.close('all') # erases previously drawn plots
canv = FigureCanvasAgg(fig)
buf = io.BytesIO()
canv.print_figure(buf, format='png')
if buf is None:
return None
buf.seek(0)
data = buf.read()
element.update(data=data)
element.update(data=buf.read())
return canv