Matplotlib Crash When Figure 1 not Closed Last
Question: I am plotting mutliple figures using Matplotlib using Python 3.4.

When the multiple figures are open and I close the windows closing the first
figure last (ie once all other figures are closed) python does not crash.

If, however, I close the first figure that was plotted first and then close
the rest Python crashes.

It seems as though you need to close the windows in such an order that the
first window that was opened must be closed last. Has anyone else experienced
and is there a solution?

Here is a trivial example code that can be used to verify:

    
    
    import matplotlib.pyplot as plt
    plt.figure(1) # the first figure
    plt.plot([1,2,3])
    plt.figure(2) # a second figure
    plt.plot([4,5,6]) 
    plt.show()
    


Answer: The way I have managed to solve this issue has been to use Qt4 as the
matplotlib backend.

Simply add the following two lines of code after importing matplotlib.

    
    
    import matplotlib as mpl
    mpl.rcParams['backend'] = "qt4agg"
    mpl.rcParams['backend.qt4'] = "PySide"
    

This is what I do on Python 3 and have no plot closing errors

