Jupyter Notebook, windows 10, Python, matplotlib, update plot

Hi everyone,

I’m new to here, I had been Googling for hours, but I still have no answer to my problem. It doesn’t imply it is a hard one, it might just imply I’m a noob :smiley_cat:.

Here my set up :

  • Jupyter Notebook
  • Windows 10
  • Python 3 : matplotlib, numpy, scipy (*)

(*) I’m not allowed to use something else so I hope it won’t make the problem harder otherwise I’ll be fine with a easiest solution even if I won’t be able to use it for my class. It will be engrossing for my future when I’ll be free to use whatever library I need.

Problem : I would like to update sequentially plot for exemple : With a for each iteration I plot a new figure with a pause time I can set up on my own.

It’s as simple as that, thanks for reading me.

Best regards.

It sounds sort of like you are trying to do what I call an animated plot. I can offer this set of plots and links to additional resources about this topic. Go in your browser to there and click the launch binder badge. You can step through running the cells in the notebook that comes up. Hopefully you can adapt some of the code for those examples to suit your needs. You’ll see the first few examples use time.spleep() to control the pause duration and so you can adjust that as you need.

It used to be the case that this was very different whether you are using the classic notebook or JupyterLab interface. I don’t know if that has changed yet with JupyterLab 3. But maybe that is moot because you say ‘Jupyter Notebook’.

My examples employ SciPy but they might not use the plots SciPy makes, and the latter may be what you need. The examples I see, such as here implies SciPy relies a lot on Matplotlib and so maybe the resources I have pointed you to will help you.

Also, I don’t know how Windows 10 may factor in. The resources I sent you to are running on a Linux machine and being served to you via your browser by the MyBinder system so you can share them easily with others who want to run your code. Maybe I am mistaken how the class is making you have to use Windows 10?


Thanks fomightez for you help.

I’m running classic notebook. And index.ipynb works flawlessly on windows 10, for once ! To go a little bit futher If I may %matplotlib notebook give me acces to the following option : Back to the previous view and Forward to the next view.
So my question is really simple, might it be possible to use this option to change plot to another. For exemple now, thanks to you, I know how to display several figures in a row with a certain amount of time between each plot (plt.pause). But now the question is, is it possible to change plot use the option back and forward.

Best regards.

I see the buttons you refer to, but I have never explored linking them. This old post which may involve different tech and this one makes me think it is possible; however, I believe those posts predate the current interface and so they may not be directly transferable. I’ve been unable to find an example with %matplotlib notebook so far. Let me know here if you find one?

I think if I wanted that ability I’d go with the solution I highlight at the bottom of the notebook I linked you to. It is described where I mention ’ includes nice controller interface’. The interface that makes is more intuitive for rewinding and forwarding. Specifically, you can see a demo of this interface by going to here and launching a binder notebook, select jupyter_nb_introduction.ipynb to run that notebook actively and then run the code in the cell under ’ Static images’ to import numpy and then run the cell under ’ pre-render animations and export to HTML’ which is the code I suggest you adapt to have rewind and forward ability.

All right, this is under investigation.

1 Like