Hello folks. I have a frustrating problem with the Canopy distribution of Python 2.7. If I try to plot graphs within code, nothing happens. The graphing window doesn't appear, but the program reports no errors. But if I type the very same sequence of commands in order at the iPython command prompt, the graph does appear! Furthermore, the graphs from my program are somehow being buffered although not displayed, because if I then plot something from the iPython command line, lo and behold, the graph from my program will also appear with it. This means that I can display my graph by the following means: after running my program, I type pylab.plot() on the command line, and my coded graph will appear. This seems to "flush" the buffer. But this is annoying, I want the program to display to graph, and not have to type another command after the program has finished. Anyway, here is a test program that has the problem:

Thanks stranac and tnknepp! Working together you've solved the problem. The pylab.show() command didn't work by itself, and putting in the line pylab.figure(figsize=(9,5)) didn't work by itself. However, when I combined them, it works perfectly and reliably! Here is the code that does work:

Another thing I discovered: in addition to displaying the sine wave graph, the program will also pop up any graph windows which had previously been buffered, if there are any. For example, if I put the line pylab.clf() immediately before the pylab.figure line in the code above, when I run the program, it actually pops up two graph windows, one at standard size and with nothing in it, as well as the sine wave graph size 9x5.

Not sure if this is a bug in the pylab software, as I assume it is meant to just pop up the graph window when pylab.plot is called, but anyway it works well now with this fix, so I'm happy!

Since there is no current figure when you run pylab.clf() pylab creates one. Personally, I do not see the use in this, though it is likely a way of avoiding troublesome errors that may arise when trying to clear a figure that doesn't exist (i.e. if a current figure does not exist, create one and clear it!).

I recommend using close('all') (or just the close command) in pylab to close your figures. I like this better than just clearing a figure.