I have some code that generates an interactive display. One plot is seen in a "magnified display," and several other plots are seen below:
https://i.stack.imgur.com/eydU7.png
When I press the "apply to all" button, I want to update the graphs in the lower row to reflect the parameters selected by the widgets. My function for this works, but the original graphs aren't cleared and the new ones are displayed under them. No amount of using plt.close()
, plt.clf()
, or any related functions has been able to solve this issue.
The graphs are generated using the interactive_output feature of the ipywidgets
package, so a function runs every time one of the widgets is updated. This function includes a plt.close()
call to remove the current figure and subsequently defines a new one. However, this doesn't happen and the new one is just plotted on top of the old one.
How do I remove the old graphs from the display when the new ones are generated?