spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
143 stars 58 forks source link

"More than 20 figures have been opened" messages from matplotlib in test logs #885

Open jameswilburlewis opened 2 weeks ago

jameswilburlewis commented 2 weeks ago

We're seeing a few of these in the test logs, for test suites that open a lot of plots:

12-Jun-24 01:17:42: /opt/hostedtoolcache/Python/3.12.3/x64/lib/python3.12/site-packages/pytplot/MPLPlotter/tplot.py:106: 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`). Consider using `matplotlib.pyplot.close()`.
  fig, axes = plt.subplots(nrows=num_panels, sharex=True, gridspec_kw={'height_ratios': panel_sizes})

It would probably be a good idea to close the plots after they're made (perhaps only if display=False to account for interactive use)