# How to call multiple Makie recipes for heterogeneous collections?

**URL:** <https://discourse.julialang.org/t/how-to-call-multiple-makie-recipes-for-heterogeneous-collections/137483>\
**Category:** Visualization\
**Tags:** makie, interactivity, observables\
**Created:** [June 7, 2026, 2:35pm UTC](https://discourse.julialang.org/t/how-to-call-multiple-makie-recipes-for-heterogeneous-collections/137483 "2026-06-07T14:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 7, 2026, 2:35pm UTC](https://discourse.julialang.org/t/how-to-call-multiple-makie-recipes-for-heterogeneous-collections/137483/1 "2026-06-07T14:35:09Z")

</div>

The MWE is self-explanatory:

```julia
using GLMakie
import Makie

# type hierarchy
abstract type G end
struct G1 <: G end
struct G2 <: G end

# define recipe for vector of G
Makie.@recipe(MyPlot, gs) do scene
  Makie.Attributes()
end

# split heterogeneous vector into homogeneous vectors
function Makie.plot!(plot::MyPlot{<:Tuple{AbstractVector{<:G}}})
  # retrieve unique types
  Gs = unique(map(typeof, plot.gs[])) # issue 1

  # register compute node and dispatch plot for each type
  for (i, G) in enumerate(Gs)
    # add indices to compute graph
    guid = Symbol(:inds, i)
    Makie.map!(plot, :gs, guid) do gs
      findall(g -> g isa G, gs)
    end

    # dispatch plot for this specific type
    inds = plot[guid][] # issue 2
    plottext!(plot, G, inds)
  end
end

# recipe for type G1
function plottext!(plot::MyPlot, ::Type{G1}, inds)
  Makie.text!(plot, inds, fill(0, length(inds)), text=fill("G1", length(inds)))
end

# recipe for type G2
function plottext!(plot::MyPlot, ::Type{G2}, inds)
  Makie.text!(plot, inds, fill(0, length(inds)), text=fill("G2", length(inds)))
end

# initialize plot
gs = Observable([G1(), G2(), G1(), G2()])
myplot(gs)

# doesn't work
gs[] = [G1(), G1()]

```

I’ve marked the code with `issue 1` and `issue 2`, which are the two places where I needed direct access to node contents. Is there any method to make this plot interactive?

---

<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 7, 2026, 3:54pm UTC](https://discourse.julialang.org/t/how-to-call-multiple-makie-recipes-for-heterogeneous-collections/137483/2 "2026-06-07T15:54:08Z")

</div>

If you know all the types at first call, you can set it up statically. If you don’t, probably easiest to use plotlist like in the other post.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 7, 2026, 4:29pm UTC](https://discourse.julialang.org/t/how-to-call-multiple-makie-recipes-for-heterogeneous-collections/137483/3 "2026-06-07T16:29:52Z")

</div>

For future reference, this is the other post:

> [@How to insert an interactive condition inside a Makie recipe?](https://discourse.julialang.org/t/how-to-insert-an-interactive-condition-inside-a-makie-recipe/137482):
>
> The following MWE is self-explanatory: using GLMakie import Makie # define recipe with condition "showlines" Makie.@recipe(MyPlot, x, y) do scene Makie.Attributes(; showlines=true ) end # toggle between scatterlines and scatter function Makie.plot!(plot::MyPlot) if plot.showlines[] # this is the root of the issue Makie.scatterlines!(plot, plot.x, plot.y) else Makie.scatter!(plot, plot.x, plot.y) end end # initialize plot x = 1:10 y = rand(10) showlines = Observable(true…
