Hello everyone, I have a question about Makie.
Just for context, I have a reactive plot that has a Makie.Colorbar
, but when the Colorbar limits are equal it breaks.
So my question is:
Can I hide/remove the Colorbar or replace it with another widget in the Makie.on
event?
MWE:
using GLMakie
function myplot(x, y, colors)
fig = Figure()
menu = Menu(fig[1, :], options=collect(propertynames(colors)))
color = Observable{Any}()
limits = Observable{Any}()
c = first(colors)
color[] = c
limits[] = extrema(c)
scatter(fig[2, 1], x, y; color)
Colorbar(fig[2, 2]; limits)
on(menu.selection) do name
c = colors[name]
color[] = c
limits[] = extrema(c)
# PROBLEM: if minimum(c) == maximum(c), hide, remove or replace Colorbar
end
fig
end
x = rand(1:9, 10)
y = rand(1:0, 10)
colors = (a=rand(1:5, 10), b=rand(5:9, 10))
myplot(x, y, colors) # works
colors = (a=rand(1:5, 10), b=fill(1, 10))
myplot(x, y, colors) # breaks