I have a simple python script as
import numpy as np import matplotlib.pyplot as plt import pylab x = np.arange(0, 5, 0.1) y = np.sin(x) plt.plot(x, y) pylab.show() If I run it from the terminal, it opens the interactive window of pylab to show the output graph. But if I run the script by Spyder, only a static image is shown in the console.
How can I tell Spyder to open the interactive graph of pylab? Or how should I modify my code to diplay an interactive graph (with the ability to zoom and enlarge).


pylabat all. From the usage guide: "pylab is a convenience module that bulk imports matplotlib.pyplot (for plotting) and numpy (for mathematics and working with arrays) in a single name space. Although many examples use pylab, it is no longer recommended." Simply useimport matplotlib.pyplot as pltand callplt.show()at the end.