# Jupyter lab plot update only the curve and not the axes

**URL:** <https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097>\
**Category:** Visualization\
**Tags:** question, package, plotting\
**Created:** [September 23, 2019, 11:27pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097 "2019-09-23T23:27:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![amit112amit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amit112amit/32/10076_2.png) [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Post date:** [September 23, 2019, 11:27pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/1 "2019-09-23T23:27:12Z")

</div>

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](https://github.com/matplotlib/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?

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [September 24, 2019, 1:20am UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/2 "2019-09-24T01:20:37Z")

</div>

[VegaLite.jl](https://github.com/queryverse/VegaLite.jl) supports interactive charts in jupyterlab. The docs for the interactive stuff are at [Selection Parameters | Vega-Lite](https://vega.github.io/vega-lite/docs/selection.html).

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [September 24, 2019, 4:15am UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/3 "2019-09-24T04:15:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [September 24, 2019, 4:44am UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/4 "2019-09-24T04:44:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![amit112amit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amit112amit/32/10076_2.png) [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Post date:** [September 24, 2019, 2:11pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/5 "2019-09-24T14:11:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amit112amit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amit112amit/32/10076_2.png) [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Post date:** [September 27, 2019, 9:19pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/6 "2019-09-27T21:19:45Z")

</div>

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

```julia
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

```

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [September 27, 2019, 10:28pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/7 "2019-09-27T22:28:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amit112amit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amit112amit/32/10076_2.png) [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Post date:** [September 27, 2019, 10:39pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/8 "2019-09-27T22:39:38Z")

</div>

Ok. Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [September 29, 2019, 3:39pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/9 "2019-09-29T15:39:54Z")

</div>

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:

```julia
@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](https://github.com/JuliaPlots/WGLMakie.jl) backend, but that’s a bit experimental at the moment AFAIU.

---

<div class="post-metadata">

**Author:** ![amit112amit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amit112amit/32/10076_2.png) [@amit112amit](https://discourse.julialang.org/u/amit112amit)\
**Post date:** [October 1, 2019, 7:13pm UTC](https://discourse.julialang.org/t/jupyter-lab-plot-update-only-the-curve-and-not-the-axes/29097/10 "2019-10-01T19:13:00Z")

</div>

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.
