On-the-fly plotting in a script

I am writing a julia script and would like to do the following:

  1. open a plot window
  2. run a few steps of my model
  3. update the plot window to show the current status of the model
  4. repeat steps 2 and 3 indefinitely

I found a few very old discussions about how to do this in a notebook setting, but nothing about how to do it from a script. Is it possible, and if so what’s the up to date way to do it?

It would be ideal if it can be done efficiently and without flickering, but if that’s not possible I will take any hack that works.

Never mind, just calling plot() in a loop seems to work just fine. For some reason I expected that to be a lot harder than it is.

It seems it’s best to run the script with julia -i, because otherwise ctrl-C causes it to hang, making the process difficult to kill.

Have a look at Makie.jl too for interactively updating plots. Especially Observables & Interaction

1 Like