Jupyter lab plot update only the curve and not the axes

Hi.
I have tried using “Interact.jl” with “PyPlot.jl” in Jupyter lab and it works. But it updates the whole figure every time I move the sliders. Thus, there is blinking. Is there something like jupyter-matplotlib that would allow the plots in Jupyter to not be images and thus allow updating only the curves and not the whole plot?

VegaLite.jl supports interactive charts in jupyterlab. The docs for the interactive stuff are at https://vega.github.io/vega-lite/docs/selection.html.

Have you tried gr instead of PyPlot? It’s usually fast enough to avoid blinking.

while we’re on this, does anyone notice @gif won’t update the file sometimes due to browser cache? is this something user should deal with via browser or jupyter can do something?

Thank you for your comments. I looked at ‘Vegalite.jl’. It has a different approach for making plots that will require some getting used to given my background with Matplotlib. I prefer using GR backend with Plots.jl.

@davidanthoff Can you point me to any short example of combining “Interact.jl slider” with VegaLite.jl in Jupyterlab? Something like following

using VegaLite, DataFrames, Interact

x = 0.0:0.01:2π
data = DataFrame(x=x, sin=sin.(x))

data |> @vlplot(:line, x=:x, y={:sin, title="sin(x)"})

@manipulate for i = 1:5
     data[:sin] = sin.(i*x)
     # How do I update the plot now?
end

I don’t think one can combine Interact.jl with VegaLite.jl, or at least I’ve never tried it.

VegaLite.jl has its own grammar of interactive graphics story, i.e. the idea is that you specify the interactivity you want in the @vlplot call itself.

Ok. Thank you for your reply.

Switching to gr() backend should fix it. If the animation is too demanding, you could try throtting the update (only allow it after some time delay). For example:

@manipulate throttle = 0.1 for i in ...
    plot(..)
end

Only updating the curves but not the axes is unfortunately not possible with Plots and it was one of the reason Makie was created. I think Makie should soon be able to run interactively in a Jupyter notebook with the WGLMakie backend, but that’s a bit experimental at the moment AFAIU.

Thank you for your reply. Yes, gr() is so fast that moving the slider appears like animation although it is making static images. I also found the throttle command. The only issue with gr() is that it does not support zooming and panning like PlotlyJS. Thank you for bringing my attention to WGLMakie.jl. I will keep an eye on it.