Skip to content

Suppress warning about opening too many figures by closing them instead of clearing them

Reese Daniel requested to merge close-figs into dev

Running the main script terminates with a warning like

AIMS.py:3403: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).                                                                                                                                                                                                                                  
  plt.figure()                                                                                                                                                                                                                                                

Because we already clear the plots after saving them to files and before exiting the plot functions, there's no reason not to close them.

In the long run, we probably want the plotting routines to return the Matplotlib figure object, but we can rewrite that once the plotting is properly modularised (along with everything else).

Merge request reports

Loading