# Update range with the same number of samples, Makie

**URL:** <https://discourse.julialang.org/t/update-range-with-the-same-number-of-samples-makie/72719>\
**Category:** General Usage\
**Tags:** question, plotting, makie\
**Created:** [December 7, 2021, 3:55pm UTC](https://discourse.julialang.org/t/update-range-with-the-same-number-of-samples-makie/72719 "2021-12-07T15:55:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [December 7, 2021, 3:55pm UTC](https://discourse.julialang.org/t/update-range-with-the-same-number-of-samples-makie/72719/1 "2021-12-07T15:55:03Z")

</div>

How to use the information from `ax.finallimits[]` to update my plot to a new range in `x` and `y` when I do zoom in or zoom out in my plot? The catch is that the number of samples needs to remain the same.

```julia
using GLMakie
fig = Figure(resolution =(600,400))
m = rand(10,10)
x = 1:10
y = 1:10
ax = Axis(fig[1,1])
heatmap!(ax, x, y, m)
lim = ax.finallimits[]
fig

```

so that when I zoom in, let’s say now my limits are from 2 to 4 in x and 3 to 6 in y but I still want 10 numbers in those intervals.

---

<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:** [December 7, 2021, 3:58pm UTC](https://discourse.julialang.org/t/update-range-with-the-same-number-of-samples-makie/72719/2 "2021-12-07T15:58:49Z")

</div>

This works, although it updates twice per limit change because I was lazy.

```julia
fig = Figure(resolution =(600,400), font = "Arial")
ax = Axis(fig[1,1])

f(x, y) = sin(x) * cos(y)
xrange = lift(ax.finallimits) do lims
    range(minimum(lims)[1], maximum(lims)[1], length = 10)
end
yrange = lift(ax.finallimits) do lims
    range(minimum(lims)[2], maximum(lims)[2], length = 10)
end

heatmap!(ax, xrange, yrange, f)

fig

```
