Skip to content

Instantly share code, notes, and snippets.

@jkrumbiegel
Created July 1, 2022 07:58
Show Gist options
  • Save jkrumbiegel/668473140b309abb4210a628932bc8c2 to your computer and use it in GitHub Desktop.
Save jkrumbiegel/668473140b309abb4210a628932bc8c2 to your computer and use it in GitHub Desktop.
glmakie row selection heatmap
using GLMakie
data = Observable(randn(30, 30))
lineindex = Observable(1)
linedata = @lift $data[:, $lineindex]
f, ax, hm = heatmap(data, axis = (; aspect = 1))
selectionrect = @lift Rect2f(0.5, $lineindex-0.5, size($data, 1), 1)
wireframe!(selectionrect, color = :white)
lines(f[1, 2], linedata)
register_interaction!(ax, :my_interaction) do event::MouseEvent, axis
if event.type === MouseEventTypes.leftclick
i = round(Int, event.data[2])
if 1 <= i <= size(data[], 1)
lineindex[] = i
end
end
end
f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment