# Best way to let axis automatically adjust in live GLMakie plot?

**URL:** <https://discourse.julialang.org/t/best-way-to-let-axis-automatically-adjust-in-live-glmakie-plot/100615>\
**Category:** Visualization\
**Created:** [June 20, 2023, 4:29pm UTC](https://discourse.julialang.org/t/best-way-to-let-axis-automatically-adjust-in-live-glmakie-plot/100615 "2023-06-20T16:29:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhinsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mhinsch/32/26676_2.png) [@mhinsch](https://discourse.julialang.org/u/mhinsch)\
**Post date:** [June 20, 2023, 4:29pm UTC](https://discourse.julialang.org/t/best-way-to-let-axis-automatically-adjust-in-live-glmakie-plot/100615/1 "2023-06-20T16:29:22Z")

</div>

I’m plotting some numbers produced by my simulation using GLMakie. The code looks somewhat like this:

```julia
data = Observable([[0.0], [0.0]])
series(data)

while sim_is_running
    # do stuff
    push!(data[][1], result1)
    push!(data[][2], result2)

    notify(data)
end

```

This seems to work fine, however, the axis limits do not adjust when new points are added to the plot. I could add a listener to `data` that manually calls `autolimits!`, but that seems a bit wasteful (not least because it will add a second redraw unless I am missing something). Is there a better way to do this?

---

<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:** [June 20, 2023, 5:05pm UTC](https://discourse.julialang.org/t/best-way-to-let-axis-automatically-adjust-in-live-glmakie-plot/100615/2 "2023-06-20T17:05:57Z")

</div>

You can call `reset_limits!` (similar to `autolimits!` but doesn’t revert `ax.limits` if it’s set) and that doesn’t redraw (drawing is separate). But it gets slower and slower the larger your data set is, because each time it has to iterate over all points of all plots. If you only care about this dataset you can just keep track of the limits yourself, update them for each new incoming piece of data, and set `limits!(ax, ...)` directly instead. This will just update the projection and ticks without iterating over all of the data.
