Update existing plot instead of showing a new one

Hi guys,

the whole plotting stuff very confuses me. For example I manage to display my plot with Plots.jl with the plotlyjs backend (it opens a new browser tab and shows my plot), and I am happy with it. However I do not understand, how exactly it works and what exactly causes the browser to open and to connect it with my plot. Because I do not understand, how it works, I do very hard modifying things the way I would like them to work.

This is my code so far, and it is working:

# Julia 1.2, using Visual Studio Code on Ubuntu

using Plots
plotly();

# x, y and l defined somewhere else...

p=plot(x[1],y[1]; label=l[1], size=(500,250), dpi=300)
display(p)
for i=2:10
    plot!(x[i],y[i]; label=l[i])
end
display(p)

You see that I have the display function twice. Now I would like that when I modify the plot somehow (for example with plot!), that the plot updates in the same window. However, everytime I call display, my browser opens a new page called file:///tmp/jl_XXXXXX.html.
I don’t know why this file is created in the first place, and how the plot is forwarded to this file.

Is it possible to create a well defined file, open it in my browser automatically, and to modify and reload that page whenever I need to? Also, If someone could explain me how display exactly works, I would be glad.

1 Like

Hm, I just figured out, there is a overwrite_figure keyword. But even when I set this to overwrite_figure=true inside the plot function, every call to display will create a new temporary file and open a new tab in my browser. Seems this keyword does not work in this constellation. Is there another way to get it to override the current plot? Is this expected behaviour or is this a bug?