MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / draw_figure

Function draw_figure

DemoPrograms/Demo_Matplotlib_Image_Elem.py:80–98  ·  view source on GitHub ↗

Draws the previously created "figure" in the supplied Image Element :param element: an Image Element :param figure: a Matplotlib figure :return: The figure canvas

(element, figure)

Source from the content-addressed store, hash-verified

78# dP
79
80def draw_figure(element, figure):
81 """
82 Draws the previously created "figure" in the supplied Image Element
83
84 :param element: an Image Element
85 :param figure: a Matplotlib figure
86 :return: The figure canvas
87 """
88
89 plt.close('all') # erases previously drawn plots
90 canv = FigureCanvasAgg(figure)
91 buf = io.BytesIO()
92 canv.print_figure(buf, format='png')
93 if buf is not None:
94 buf.seek(0)
95 element.update(data=buf.read())
96 return canv
97 else:
98 return None
99
100
101

Callers 1

mainFunction · 0.70

Calls 3

closeMethod · 0.45
updateMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected