# Refreshing a WGLMakie plot in realtime in jupyter notebook

**URL:** <https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300>\
**Category:** General Usage\
**Tags:** plotting, makie\
**Created:** [January 28, 2025, 1:51pm UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300 "2025-01-28T13:51:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)\
**Post date:** [January 28, 2025, 1:51pm UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/1 "2025-01-28T13:51:53Z")

</div>

![Screenshot 2025-01-28 214040](https://global.discourse-cdn.com/julialang/original/3X/1/1/1121bb090be93dfea55607e6564f1e48194e9c1c.png)  
The concept is just like the above picture (a Mathematica notebook). The use case is monitoring in realtime a field in numerical evolution. Is it possible using WGLMakie in jupyter notebook? Or other alternative suggestions?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 28, 2025, 2:26pm UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/2 "2025-01-28T14:26:00Z")

</div>

Yes, see e.g: [Animations | Makie](https://docs.makie.org/stable/explanations/animation#Animations-using-Observables)  
Of course you won’t need the `record`.

---

<div class="post-metadata">

**Author:** ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)\
**Post date:** [January 29, 2025, 3:59am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/3 "2025-01-29T03:59:53Z")

</div>

Thanks. I think you mean the Animating a plot “live” section:

> **[Animations | Makie](https://docs.makie.org/stable/explanations/animation#Animating-a-plot-%22live%22)**
>
> Create impressive data visualizations with Makie, the plotting ecosystem for the Julia language. Build aesthetic plots with beautiful customizable themes, control every last detail of publication quality vector graphics, assemble complex layouts and...

because the `record` is needed otherwise.  
So I copied the following code from there:

```julia
using WGLMakie

points = Observable(Point2f[randn(2)])

fig, ax = scatter(points)
limits!(ax, -4, 4, -4, 4)

fps = 60
nframes = 120

for i = 1:nframes
    new_point = Point2f(randn(2))
    points[] = push!(points[], new_point)
    sleep(1/fps) # refreshes the display!
end

```

while changed `GLMakie` to `WGLMakie`. But nothing happened in the jupyter notebook. No plot could be seen.  
`GLMakie` just works well, refreshing the plot in realtime in an independent window. But as I said in the OP, what I need is a plot embedded in jupyter notebook that can be refreshed.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [January 29, 2025, 9:48am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/4 "2025-01-29T09:48:10Z")

</div>

> [@photor](#):
>
> while changed `GLMakie` to `WGLMakie`. But nothing happened in the jupyter notebook. No plot could be seen.

You need to either `display` or return the plot from the cell somehow. E.g. here’s a little example I made that does the same thing as your Mathematica snippet:

Note: making this example was a bit of a pain in the ass for me, and I ran into lots of weird buggy behaviour and I have no idea if it was firefox’s fault, WGLMakie’s fault, or Jupyter’s fault.

---

<div class="post-metadata">

**Author:** ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)\
**Post date:** [January 29, 2025, 10:21am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/5 "2025-01-29T10:21:24Z")

</div>

Many thanks! Your method is definitely working in jupyter with a web browser, but it is not working in vs-code. Any solutions?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 29, 2025, 10:23am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/6 "2025-01-29T10:23:01Z")

</div>

What are you doing with VSCode exactly?  
VSCode notebooks aren’t supported yet.  
Otherwise, you need an explicit `display(figure)` call, if you dont have cells.

---

<div class="post-metadata">

**Author:** ![photor](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/photor/32/14343_2.png) [@photor](https://discourse.julialang.org/u/photor)\
**Post date:** [January 29, 2025, 10:41am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/7 "2025-01-29T10:41:31Z")

</div>

Just using vs-code to run jupyter notebooks doing numerical simulation. On some cloud platforms, there is no option to run jupyter with a web browser, so only vs-code can be used. You can have a look here:

> **[Cloud Studio](https://ide.cloud.tencent.com/)**
>
> CODING Anytime Anywhere

Thanks.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [January 29, 2025, 11:09am UTC](https://discourse.julialang.org/t/refreshing-a-wglmakie-plot-in-realtime-in-jupyter-notebook/125300/8 "2025-01-29T11:09:57Z")

</div>

They will need to explicitly support [Bonito.jl](https://github.com/SimonDanisch/Bonito.jl), e.g. like [JuliaHub’s cloud VSCode IDE](https://help.juliahub.com/juliahub/stable/tutorials/julia_ide/).  
That’s because they have to proxy through the Websocket connection that Bonito needs to render + update the WGLMakie plots.
