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

Function draw

DemoPrograms/Demo_Matplotlib_Ping_Graph_Large.py:88–106  ·  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

86
87
88def draw(element, figure):
89 """
90 Draws the previously created "figure" in the supplied Image Element
91
92 :param element: an Image Element
93 :param figure: a Matplotlib figure
94 :return: The figure canvas
95 """
96
97 # plt.close('all') # erases previously drawn plots
98 canv = FigureCanvasAgg(figure)
99 buf = io.BytesIO()
100 canv.print_figure(buf, format='png')
101 if buf is not None:
102 buf.seek(0)
103 element.update(data=buf.read())
104 return canv
105 else:
106 return None
107
108# ================================================================================
109# Function: MAIN

Callers 1

mainFunction · 0.85

Calls 2

updateMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected