Makie.jl - Subplots + hover information

Hi all. I have a general question regarding Makie.jl, subplots and hover information.

I would like to recreate a plot with some subplots in which the hover information of ALL the data-series is shown. There would be 2 ways:

  • Information on every data-series when hover 1 of the series, like this one example from Plotly-Python (hoverinfo_subplots)

  • Vertical hoverline across all subplots showing information of all the data-series in all subplots like the following image:

Is this easy doable with Makie.jl?

Thanks!

As a starting point, I found this: Inspecting data | Makie

Easily doable is a stretch, but you can build something like it. This is a rough sketch

f = Figure()

ax = Axis(f[1, 1])

lins = [lines!(ax, 1:100, cumsum(randn(100)), label = "$i") for i in 1:4]

vlin = vlines!(ax, 0.0, visible = false, color = :gray80)
too = tooltip!(ax, 0.0, 0.0, "", visible = false)
translate!(too, 0, 0, 100)

function joint_hover_info(event::MouseEvent, axis)
    x, y = event.data
    if event.type == Makie.MouseEventTypes.enter
        vlin.visible = true
        too.visible = true
    elseif event.type == Makie.MouseEventTypes.over
        update!(vlin, arg1 = x)

        io = IOBuffer()
        println(io, "x: ", round(x, digits = 3))
        for lin in lins
            # TODO: this logic is very rough
            i = findfirst(_x -> _x >= x, lin.arg1[])
            i === nothing && continue
            println(io, lin.label[], ": ", round(lin.arg2[][i], digits = 3))
        end
        str = String(take!(io))

        update!(too, arg1 = x, arg2 = y, arg3 = str)
    elseif event.type == Makie.MouseEventTypes.out
        vlin.visible = false
        too.visible = false
    end
    return
end

register_interaction!(joint_hover_info, ax, :joint_hover)

f
1 Like