|
From: Kelson Z. <kb...@co...> - 2013-01-17 08:08:08
|
So I looked into it and the reason calling the show method for a Figure/FigureManager causes the figure to be visible only for an instant is that, at least in the case for tkagg, there is no call to a function that blocks until the figure window is closed and as a result the figure is displayed then the call to show ends, the figure closes, and the program moves on. This is in contrast to the behavior of the callable object invoked by pyplot.show() which calls a mainloop method to block. Since I am not super familiar with the internals of Matplotlib I am not sure the best way to fix this, but one option, in the case of tkagg, is to add a call to tk.mainloop() to the end of FigureManagerTkAgg.show() as is done in tkagg's Show object. Just my 2 cents On 1/16/13 10:23 AM, Benjamin Root wrote: > > > On Wed, Jan 16, 2013 at 5:50 AM, Kelson Zawack <kb...@co... > <mailto:kb...@co...>> wrote: > > Ok, I understand about agg, but I am still a bit confused. First > when I run the suggested code using whatever the default backend > is the figure is only displayed for a second and then it goes away > and the program ends. I guess what I am really interested in is > what plt.figure() does. It seems to be creating a figure manager > which has a canvas and a figure in it, but which one of these is > responsible for the showing/saving to file? > > Thanks for your help > > > If the plot only appears for a moment, then that would be a bug. > Could you double-check which version of matplotlib you are running? > > Ben Root |