Python Matplotlib hangs when asked to plot a second chart (after closing first chart window)
matplotlib, python
Solution
Apparently, this is caused by a bug in the tkinter backend. See, e.g., https://bugs.launchpad.net/ubuntu/+source/matplotlib/+bug/313834 . It's being worked on... If you can regress to a slightly older tkinter library, that should be a workaround for the time-being (I ran into this same thing a couple of weeks ago, and that was my only hope).
Problem
Weird behaviour, I'm sure it's me screwing up, but I'd like to get to the bottom of what's happening: I am running the following code to create a very simple graph window using matplotlib: ``` >>> import matplotlib.pyplot as plt >>> fig = plt.figure() >>> ax = fig.add_subplot(111) >>> ax.plot((1, 3, 1)) [<matplotlib.lines.Line2D object at 0x0290B750>] >>> plt.show() ``` and as expected I get the chart one would expect, in a new window that has popped up, containing a very simple blue line going from 1 to 3 back to 1 again on y axis, with 0, 1, 2 as the x axis points (just as example). Now I close the graph window (using cross button in the top right under windows). This gives me control to the interpreter, and I start again, creating new objects: ``` >>> >>> fig1 = plt.figure() >>> bx = fig1.add_subplot(111) >>> bx.plot((1, 3, 1)) [<matplotlib.lines.Line2D object at 0x029E8210>] >>> plt.show() ``` This time though, I get a window frame, with nothing in it (just the frame, no white background nothing), and the whole bang shoot hangs. I have to "end task", the python interpreter is terminated by the system and I get a command prompt back. Similar behaviour on a mac (except it does actually plot the graph first, before also hanging). So somehow Python and/or matplotlib doesn't want me to close the window manually. Anybody know what's going on and what I should be doing? What I'd like to do is play around with different plots from within the interpreter, and obviously this behaviour doesn't help. I know I could use "Ipython -pylab" but in the interests of learning, I want to understand the above error. Thanks.