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

Antony Lee antony.lee at institutoptique.fr
Fri Aug 16 04:46:13 EDT 2019


Hi,
You can probably either call plt.close(fig) after savefig to close the
figure (likely best), or adjust rcParams["figure.max_open_warning"] to a
large enough number (at the risk of running out of memory).
Antony

On Fri, Aug 16, 2019 at 12:44 AM Neal Becker <ndbecker2 at gmail.com> wrote:

> 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
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190816/f636b78c/attachment.html>


More information about the Matplotlib-users mailing list