# Fixing plot position during an animation for CairoMakie

**URL:** https://discourse.julialang.org/t/fixing-plot-position-during-an-animation-for-cairomakie/104709
**Category:** Visualization
**Tags:** makie, animations
**Created:** [October 7, 2023, 7:23pm UTC](https://discourse.julialang.org/t/fixing-plot-position-during-an-animation-for-cairomakie/104709 "2023-10-07T19:23:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Varun\_V](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/varun_v/32/53199_2.png) [@Varun\_V](https://discourse.julialang.org/u/Varun_V)
#### Post date: [October 7, 2023, 7:23pm UTC](https://discourse.julialang.org/t/fixing-plot-position-during-an-animation-for-cairomakie/104709/1 "2023-10-07T19:23:23Z")

</div>

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.

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

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [October 7, 2023, 9:16pm UTC](https://discourse.julialang.org/t/fixing-plot-position-during-an-animation-for-cairomakie/104709/2 "2023-10-07T21:16:49Z")

</div>

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
