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)
| 86 | |
| 87 | |
| 88 | def 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 |