I have a simple python script which plots some graphs in the same figure. All graphs are created by the draw() and in the end I call the show() function to block.
The script used to work with Python 2.6.6, Matplotlib 0.99.3, and Ubuntu 11.04. Tried to run it under Python 2.7.2, Matplotlib 1.0.1, and Ubuntu 11.10 but the show() function returns immediately without waiting to kill the figure.
Is this a bug? Or a new feature and we'll have to change our scripts? Any ideas?
EDIT: It does keep the plot open under interactive mode, i.e., python -i ..., but it used to work without that, and tried to have plt.ion() in the script and run it in normal mode but no luck.
Plotting from an IPython shell Some changes (such as modifying properties of lines that are already drawn) will not draw automatically: to force an update, use plt. draw() . Using plt. show() in Matplotlib mode is not required.
Answer #6: plt. show() and plt. draw() are unnecessary and / or blocking in one way or the other.
Plot a line using plot() method. Display the figure using Show() method. To display the figure, use Show() method with block=False.
In interactive tools, You need to use plt. show() when all your plots are created.
I had this same problem, and it was caused by calling show()
on the Figure object instead of the pyplot object.
Incorrect code. Causes the graph to flash on screen for a brief instant:
import matplotlib.pyplot as plt x = [1,2,3] y = [5,6,7] fig = plt.figure() plt.plot(x, y) fig.show()
Last line should be as follows to show the graph until it is dismissed:
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With