# \[GeoMakie\] contourf animation changes color range for each update of "record"

**URL:** https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403
**Category:** New to Julia
**Tags:** makie
**Created:** [August 6, 2022, 4:04pm UTC](https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403 "2022-08-06T16:04:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ManuelFossa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manuelfossa/32/36305_2.png) [@ManuelFossa](https://discourse.julialang.org/u/ManuelFossa)
#### Post date: [August 6, 2022, 4:04pm UTC](https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403/1 "2022-08-06T16:04:34Z")

</div>

I have a simple GeoAxis contourf animation, that iterates over time.  
The problem is that at each update of the record function, the color range changes, which can be seen as the colorbar changes ticks constantly. I would like the color range to be absolute over all timesteps

Here is my code (using GLMakie, GeoMakie)

> ```
> total_crange = colorLims #the extrema over all data
> field = structFun #This is the data with the third dimension as time
> field = permutedims(field,(2,1,3))
> colorRange = repeat([0 1],size(field,3),2) # I repeat the colorRange N times 
> points = (lonMsa, latMsa) 
> idx = Observable(1)
> 
> data = lift(idx) do i
> field[:, :, i] 
> end
> 
> titlestr = lift(x -> "scale(hours) = "*string(x), idx)
> 
> colorRange2 = lift(idx) do i
> colorRange[i,:]
> end
> 
> fig = Figure(resolution = (2560 , 1440))
> ga = GeoAxis(
> fig[1, 1],
> coastlines = true,
> dest = "+proj=eqc",
> lonlims = lonLim,
> latlims = latLim,
> title = titlestr)
> 
> sp = contourf!(ga, lons, lats, data ; shading=false, colormap=:inferno, colorrange=colorRange2)
> scatter!(ga , points , color="white" , markersize=20)
> cb = Colorbar(fig[1, 2],sp)
> 
> record(fig, imgName, 1:size(field, 3); framerate = 30) do i
> idx[] = i
> end
> 
> ```

---

<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: [August 6, 2022, 6:49pm UTC](https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403/2 "2022-08-06T18:49:08Z")

</div>

Contourf uses the colormap and picks the colors from it using the different levels. So it doesn’t use the passed colorrange. You could probably fix the levels instead of the colorrange?

---

<div class="post-metadata">

### Author: ![ManuelFossa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manuelfossa/32/36305_2.png) [@ManuelFossa](https://discourse.julialang.org/u/ManuelFossa)
#### Post date: [August 7, 2022, 1:59pm UTC](https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403/3 "2022-08-07T13:59:56Z")

</div>

Yes, that’s what I did, but I reiterate the same code on different data, and I sometimes have the error “no meshes to merge” associated with the fixed levels (if i remove the fixed levels option from contourf the error disappears).

---

<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: [August 7, 2022, 2:10pm UTC](https://discourse.julialang.org/t/geomakie-contourf-animation-changes-color-range-for-each-update-of-record/85403/4 "2022-08-07T14:10:37Z")

</div>

Maybe it doesn’t like empty vectors, if you can, make a minimal reproducing example and open an issue on Github
