[Matplotlib-users] Mac OS: Can't get rid of 286 figures.

Juan Nunez-Iglesias jni at fastmail.com
Mon Mar 9 07:52:47 EDT 2020


Hi Steve,

In addition to Scott’s excellent list of resources, I’d like to recommend “effective matplotlib” from Practical Business Python:

https://pbpython.com/effective-matplotlib.html

It answers a lot of your questions about the hierarchy of objects of matplotlib.

Please bear in mind that matplotlib is an old library (started in 2001 I believe) so it’s hard to ensure that all information out there is totally up to date. This *is* the right forum to get up to date information. On Stack Overflow, be sure to look for more recent answers than the “accepted” one, in case there is a newer way of doing things.

Juan.

> On 8 Mar 2020, at 7:49 am, Steve Morris <steve at judgement.com> wrote:
> 
> 
> I am new to macplotlib and can only do the simplest things but there are many hidden complexities I can't figure out that are now killing me. My big problem is everytime I plot I get a new 'figure' which I first thought was just a mysterious incrementing number but in fact seems to be some kind of persistent object which consumes resources and won't go away.  I don't even know what a figure is. Where does it exist? Where is it's state recorded? How do I get rid of them? Now I have so 'figures' many that performance is degraded and matplotlib is becoming unusable. I have many times closed them all by patiently clicking the close box of all 286 (now empty) windows but that apparently only hides them because they all pop up again when I make a new plot. I tried killing python but they all reappear the next time I run a python script. The top of my plot script now has the following code but it apparently doesn't do anything:
>     plt.close('all')
>     for i in range(285):
>         plt.close(i)
> 
> I rebooted but the mess all comes back.
> 
> From many google searches I've recently discovered this is all apparently part of something normally hidden called a backend which is another thing I never heard of before this problem got out of control. I started using matplotlib from various online pyplot tutorials. The words 'close', 'backend' and 'figure' were never mentioned in any of them, so I had no warning.
> 
> My questions:
> 
> 1) Is this the right forum for this problem?
> 2) is there an easy way to get rid of figures. Can I reset or uninstall/reinstall something that will allow me to start over so I can use matplotlib again?
> 3) Where is this hidden infrastrastructure documented? What is its name? What keywords do I need to google to figure this out.
> 4) How do I do simple plots which go away when I am done looking at them? I have no current need for persistent plots.
> 5) Why is this so hard? I just want to plot some data.
> 
> Thanks,
> 
> -steve
> 
> Versions:
> Python 3.7.6 installed by homebrew
> Matplotlib 3.0.3
> OS: Catalina 10.15.3
> MacBook Pro
> 
> 
> _______________________________________________
> 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/20200309/c3a85f1f/attachment.html>


More information about the Matplotlib-users mailing list