Fixing plot position during an animation for CairoMakie

Hello,

I want to animate a series of heatmaps and save it to a video but when I try, the heatmap does not stay in the same place and shakes (its position changes slightly for each frame). Below is code for a minimum working example to show what I mean by shaking frames.

using CairoMakie

fig, ax, hm = heatmap(rand(10, 10))
Colorbar(fig[1, 2], hm)
colsize!(fig.layout, 1, Aspect(1, 1.0))
resize_to_layout!(fig)

record(fig, "animation.mp4", 1:100) do i
    hm[1] = rand(10, 10)*rand([1, 0.01])
end

I think the reason might be the colorbar ticks when it changes from values of the order 0.001 to 0.1. I’ve been unsuccessful in finding a way to ensure a fixed formatting style (for example 1.1 e-2).

I want the animation to stop shaking.

to fix the color limits and therefore the changes in the colorbar, set colorrange = (min, max) on the heatmap. If you don’t want that but just don’t want the slight changes in colorbar tick values to affect the layout, you can fix it at some value. One way is to call tight_ticklabel_spacing!(colorbar) which will fix the spacing to the value at that time. If that’s to little, you can also set the spacing manually. The attribute is called colorbar.ticklabelspace or so