The following Python script make a plot (of the function x^2) and shows it:
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,11)
y=x**2
plt.plot(x,y)
plt.show()
All very well, but what I've noticed is that the Python shell does not remain 'available' after running this script. Specifically (see figure below), the cursor blinks below the last command prompt (">>>") and nothing I type appears next to a command prompt. Only after I close the figure can I type in the command prompt again.
Does anybody know how to keep the plot and the command prompt simultaneously? (I'm running iPython on Linux; I've run similar scripts on Windows using the Enthought Python Distribution and not experienced such problems).
P.S. I've tried adding plt.ion() to the script, and although it does keep the command line available, it yields a blank figure (see below). Entering "%run plot_test.py" in the shell gives "SyntaxError: invalid syntax" with "%" highlighted.