And in case you come here, like I did, looking to do the same thing for plots in a Julia notebook in Jupyter, using Plots, you can use:
IJulia.clear_output(true)
so for a kind of animated plot of multiple runs
if nrun==1
display(plot(x,y)) # first plot
else
IJulia.clear_output(true) # clear the window (as above)
display(plot!(x,y)) # plot! overlays the plot
end
Without the clear_output call, all plots appear separately.