Makie - Colorbar in plot recipe

TLDR: Is it possible to add a Colorbar directly inside a plot recipe ?

I have a graph-like data structure called MTG where each node stores a mesh and attributes. I made a recipe that extends the MeshViz.jl Viz recipe to my input type (by the way is this type piracy or is it fine to do that?). What the recipe does is recursively call viz! (from MeshViz.jl) to plot each mesh into the scene. Now the user can color each mesh based on an attribute, such as the area of the mesh or whatever.

To do so, the recipe computes the range of values found in the MTG and then get the color of each mesh based on that range, and pass that color to each call to viz!() (one for each mesh). Now if the user needs a Colorbar, it will work, and here’s an example for a coffee plant:

# ]add https://github.com/VEZY/PlantGeom.jl
using PlantGeom
using CairoMakie

file = joinpath(dirname(dirname(pathof(PlantGeom))), "test", "files", "coffee.opf")
opf = read_opf(file)
f, ax, p = viz(opf, color = :Area)
Colorbar(f, label = "Area", colormap = :viridis)

But of course the range of values is wrong (0:1), they should span from ~0.1-132.0.

I would like to build the Colorbar directly inside the recipe to avoid this, but then I need access to the figure apparently, and i don’t know how to do that.

I found a somewhat similar question here but the solution doesn’t work with the latest version of Makie. I tried replacing Makie.FigurePosition with Makie.GridPosition with no success.

The recipe in question is here: PlantGeom.jl/opf_recipe.jl at main · VEZY/PlantGeom.jl · GitHub
It extends the following recipe: MeshViz.jl/MeshViz.jl at f042791a6d44caa302ece57678c4c5b4e9635899 · JuliaGeometry/MeshViz.jl · GitHub

For the record, what I would like to get can be achieved like this:

# ]add https://github.com/VEZY/PlantGeom.jl
using PlantGeom
using CairoMakie

file = joinpath(dirname(dirname(pathof(PlantGeom))), "test", "files", "coffee.opf")
opf = read_opf(file)
range_val = extrema(descendants(opf, :Area, ignore_nothing = true))
f = Figure()
viz(f[1, 1], opf, color = :Area)
Colorbar(f[1, 2], label = "Area", colormap = :viridis, limits = Float64.(range_val))
f

But I don’t want to put the burden of doing all that on the user, that’s why I would like to compute it inside the recipe if possible. Any idea how I could do that ?