Add plt.ion() before each plt.show()

There was an error that memory was not released after closing charts.
While was making coursera assignment I'd met process consumed more than 3GB.
So I've add plt.ion() (interactive mode ) before each plt.show() and it seems to work.