12 Jan 2021

Instant Update Plots in Jupyter Notebook

收藏到CSDN网摘

Jupyter Notebook is a very effective toolkit for both teaching and learning. The interactive mode is straightforward for demonstrating the logic behind the code blocks and explaining how the programme works segment by segment. With the help of powerful Matlab-equivalent matplotlib library, data plotting can be easilly implemented. However, from time to time, you might miss Matlab's `hold on` capability that enables the user draw on and update the plot instantly without producing multiple figures that flood your screen. In Jupyter notebook, if the plt.show() was called without a loop it will produce multiple outputs as many as your loop count, which is not convenient. To make it works in the same way as Matlab's `hold on`, all we need to do is: