At the end of the last function I call in one of my programs, I have the following code to plot a simple color plot.
plt.figure() plt.pcolormesh(X,Y,Z) plt.colorbar() plt.show()
Afterwords I return to main and my program is complete. The plot displays as expected, however when I go to close it using the x button in the corner (on ubuntu), my program doesn't end. It just hangs there with a process running. How can I correct this?
Answer #6: plt. show() and plt. draw() are unnecessary and / or blocking in one way or the other.
Plotting from an IPython shell Using plt. show() in Matplotlib mode is not required.
matplotlib-terminal The library is optimized for Gnome Terminal with Ubuntu Mono font. Nevertheless 'block' and 'braille' renderers should work with most modern terminals.
The plot() function is used to draw points (markers) in a diagram. By default, the plot() function draws a line from point to point. The function takes parameters for specifying points in the diagram. Parameter 1 is an array containing the points on the x-axis.
your matplotlib might be running in non-interactive mode for some reason. I am not sure how to prevent that in your local configuration but if you add either this:
plt.ion()
or this:
matplotlib.interactive(True)
somewhere at the beginning of your script, it should change the behaviour of your plots.
For interactive mode, You need this at the head of file:
import matplotlib matplotlib.use("TkAgg")
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