MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / draw_figure

Function draw_figure

DemoPrograms/Demo_Matplotlib_Embedded_TEMPLATE.py:162–180  ·  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

160# ----------------------------- The draw figure helpful function -----------------------------
161
162def draw_figure(element, figure):
163 """
164 Draws the previously created "figure" in the supplied Image Element
165
166 :param element: an Image Element
167 :param figure: a Matplotlib figure
168 :return: The figure canvas
169 """
170
171
172 plt.close('all') # erases previously drawn plots
173 canv = FigureCanvasAgg(figure)
174 buf = io.BytesIO()
175 canv.print_figure(buf, format='png')
176 if buf is None:
177 return None
178 buf.seek(0)
179 element.update(data=buf.read())
180 return canv
181
182
183# ----------------------------- The GUI Section -----------------------------

Callers 1

mainFunction · 0.70

Calls 3

closeMethod · 0.45
updateMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected