What I use involves using the classic notebook interface.
Then you put
%matplotlib notebook at the first line of the notebook cell and have the code for your animated matplotlib plot or plots and subplots below. As it runs it will show it in the notebook output area.
This won’t work in JupyterLab as the
%matplotlib inline approach doesn’t make an updating plot. I just get the end result if I have it set to loop a set amount. And the
%matplotlib notebook presently fails in JupyterLab.
There is a demo notebook launchable from here. (For direct to Binder session link, click here.) I basically loop and update that plot with new data, clearing the old with
ax.clear() and control that with a sleep interval.
There is a package to do animated plots in notebooks at https://animatplot.readthedocs.io/en/latest/gallery/Nuke.html. I haven’t looked at the behind the scenes approach to see how it compares to what I had working.