# Makie does not update the plot during an animation

**URL:** <https://discourse.julialang.org/t/makie-does-not-update-the-plot-during-an-animation/91109>\
**Category:** General Usage\
**Tags:** makie, glmakie, animations\
**Created:** [December 1, 2022, 5:31pm UTC](https://discourse.julialang.org/t/makie-does-not-update-the-plot-during-an-animation/91109 "2022-12-01T17:31:59Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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 2, 2022, 6:49pm UTC](https://discourse.julialang.org/t/makie-does-not-update-the-plot-during-an-animation/91109/14 "2022-12-02T18:49:59Z")

</div>

Multiple values are the achilles heel of the observable workflow. The problem is this:

Here, A triggers B and C, and both trigger D. In order to avoid a double update of D, A should first do `B.val = new_value`, then `C[] = new_value`.

```julia
     ┌─────┐
   ┌─┤ A ├─┐
   │ └─────┘ │
   │ │
   │ │
┌──▼──┐ ┌──▼──┐
│ B │ │ C │
└──┬──┘ └──┬──┘
   │ │
   │ │
   │ ┌─────┐ │
   └►│ D ◄─┘
     └─────┘

```

Now B has another listener, E. We can’t do `B.val = ...` anymore because `E` won’t be updated. But we can still do `C.val = ...` and `B[] = ...`.

```julia
          ┌─────┐
        ┌─┤ A ├─┐
        │ └─────┘ │
        │ │
        │ │
     ┌──▼──┐ ┌──▼──┐
   ┌─┤ B │ │ C │
   │ └──┬──┘ └──┬──┘
   │ │ │
   │ │ │
┌──▼──┐ │ ┌─────┐ │
│ E │ └►│ D ◄─┘
└─────┘ └─────┘

```

But if `C` also has a second listener, `F` this is impossible:

```julia
          ┌─────┐
        ┌─┤ A ├─┐
        │ └─────┘ │
        │ │
        │ │
     ┌──▼──┐ ┌──▼──┐
   ┌─┤ B │ │ C ├─┐
   │ └──┬──┘ └──┬──┘ │
   │ │ │ │
   │ │ │ │
┌──▼──┐ │ ┌─────┐ │ ┌──▼──┐
│ E │ └►│ D ◄─┘ │ F │
└─────┘ └─────┘ └─────┘

```

You cannot avoid updating both `B` and `C` if you want to trigger their listeners `E` and `F`, which means `D` is updated twice. But if `B` and `C` store arrays whose lengths change with the update of `A`, it can be that the first update of `D`, after `B` is triggered, errors because `B` and `C` have different lengths in that moment. In that case it’s _impossible_ to update all observables correctly. We’re still trying to figure out ways in which we can make the updating process simpler, but it’s a thorny issue and observables are deeply ingrained in the whole codebase, so we must be careful not to break anything with a “fix”.

I say this because you asked what to do with a tuple resulting from `lift`. But this usually happens because one calculates multiple input arguments for an inner plot object from input observables. In that case, one has to define all the observables beforehand, and carefully update them inside an `on` or `onany` function with `obs.val = ...` and only once (if possible) with `obs[] = ...` so that one doesn’t trigger duplicate updates downstream. But as I showed, this is sometimes impossible. Here’s one example of such a thing: [Makie.jl/contourf.jl at master · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/blob/master/src/basic_recipes/contourf.jl#L125)  
The `colors` observable is not triggered, its content array is just mutated. This way the downstream `poly` will have access to the new colors when its input observable `polys` is triggered. This way `polys` and `colors` can always have the same length from the perspective of the `poly` plot. But this wouldn’t work if something internal to `poly` relied on the `color` observable actually triggering…

---

_[View the full topic](https://discourse.julialang.org/t/makie-does-not-update-the-plot-during-an-animation/91109)._
