python 2.7 - Matplotlib: Displaying and closing a plot using a loop -
using matplotlib , loop, possible display plot given period of time , have close when loop done?
i have tried following, plot remains open , loop doesn't end:
import matplotlib.pyplot plt import psychopy x = [34.00,108.00,64.00,99.00,99.00,51.00] y = [5.00,17.00,11.00,8.00,14.00,5.00] scatter(x, y, color = "black") clock = core.clock() while clock.gettime() < 10.0: plt.show() plt.close()
thanks
you can use interactive mode plt.ion()
in combination plt.pause()
.
e.g. show window 5 seconds:
import matplotlib.pyplot plt x = [34.00,108.00,64.00,99.00,99.00,51.00] y = [5.00,17.00,11.00,8.00,14.00,5.00] plt.scatter(x, y, color = "black") plt.ion() plt.draw() plt.pause(5)
Comments
Post a Comment