0

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?

obro39
  • 11
  • 3
  • Well, you don't show any code here, so we don't know how you display it in the first place, but surely `plt.close()` will not remove a png image from the jupyter notebook output cell. – ImportanceOfBeingErnest Jul 29 '19 at 19:36
  • @ImportanceOfBeingErnest unfortunately I can't show the code, it's very large and designed for use with a specific dataset. To your second point, I apologize because I should have included more information in my question. Please see the update, thanks. – obro39 Jul 29 '19 at 20:41
  • You need to use a toy example that exposes the problem (no one wants to read through 100+ lines of code anyways). See [mcve] or http://sscce.org – ImportanceOfBeingErnest Jul 29 '19 at 20:42

0 Answers0