[Matplotlib-users] mplcairo multipage pdf and too many figures open

Neal Becker ndbecker2 at gmail.com
Thu Aug 15 18:43:52 EDT 2019


I've been using mplcairo multipage pdf.  The pattern I use is:

from mplcairo.multipage import MultiPage
cm = MultiPage(ap_args.output)
 
with cm as pdf:
  fig,ax = plt.subplots()
  do something
  pdf.savefig(fig)

  fig2,ax2 = plt.subplots()
  do something
  pdf.savefig(fig2)
...

after 20 figures:
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`).

What is the proper way to use mplcairo.multipage to avoid this issue?

Thanks,
Neal



More information about the Matplotlib-users mailing list