# Dynamically updating plots (heatmap) in Gtk4.jl and Gtk4Makie.jl

**URL:** https://discourse.julialang.org/t/dynamically-updating-plots-heatmap-in-gtk4-jl-and-gtk4makie-jl/131653
**Category:** Visualization
**Created:** [August 17, 2025, 1:46pm UTC](https://discourse.julialang.org/t/dynamically-updating-plots-heatmap-in-gtk4-jl-and-gtk4makie-jl/131653 "2025-08-17T13:46:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dopamine](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@dopamine](https://discourse.julialang.org/u/dopamine)
#### Post date: [August 17, 2025, 1:46pm UTC](https://discourse.julialang.org/t/dynamically-updating-plots-heatmap-in-gtk4-jl-and-gtk4makie-jl/131653/1 "2025-08-17T13:46:49Z")

</div>

I’ve been trying to set up a Makie plot (using GLMakie) inside a GtkFrame (Gtk4.jl) and update it programmatically on demand. I can make it work with CairoMakie, but currently trying to use GLMakie instead to minimize latency and jitter. Any advice would be appreciated.

With the following example, I can set up a heatmap inside a GtkFrame/Window, but can’t seem to update the heatmap. I’ve also tried it without a observable, which also doesn’t work e.g.:

```julia
hm[3][] = new_data

```

```julia
using Gtk4, Gtk4Makie, GLMakie, Makie, Random

const W, H = 800, 500 # desired GL surface size inside the frame

# Window + layout
win = GtkWindow(; title = "Makie in GtkFrame (fixed size)", visible = false, resizable = false)
vbox = GtkBox(:v; spacing = 8)
win[] = vbox

frame = GtkFrame("Heatmap")
push!(vbox, frame)

# Makie widget (wraps a GtkGLArea)
glw = GtkMakieWidget()

# Lock the GTK widget to W×H and prevent expansion
set_gtk_property!(glw, :width_request, W)
set_gtk_property!(glw, :height_request, H)
set_gtk_property!(glw, :hexpand, false)
set_gtk_property!(glw, :vexpand, false)

frame[] = glw

# Build Makie figure with the NEW keyword:
fig = Figure(size = (W, H)) # <- use `size`, not `resolution`
ax = Axis(fig[1, 1], aspect = DataAspect())

Z = Observable(rand(Float32, 600, 400))
hm = heatmap!(ax, Z; interpolate = false, colorrange = (0f0, 1f0))
Colorbar(fig[1, 2], hm)

push!(glw, fig) # attach the figure to the GTK widget

show(win)

function push_new_data!()
    @inbounds rand!(Z[])
    notify(Z)
    reveal(glw)
end

```

---

<div class="post-metadata">

### Author: ![dopamine](https://avatars.discourse-cdn.com/v4/letter/d/e9a140/32.png) [@dopamine](https://discourse.julialang.org/u/dopamine)
#### Post date: [September 18, 2025, 1:56pm UTC](https://discourse.julialang.org/t/dynamically-updating-plots-heatmap-in-gtk4-jl-and-gtk4makie-jl/131653/2 "2025-09-18T13:56:13Z")

</div>

FYI for anyone who has the same problem, I tried all possible permutations of data assignment, but still lots of allocations! Ended up drawing it with Cairo.jl, which worked well.
