# Hide/Remove/Replace widgets from Makie.jl reactive plots

**URL:** <https://discourse.julialang.org/t/hide-remove-replace-widgets-from-makie-jl-reactive-plots/106029>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [November 10, 2023, 11:36am UTC](https://discourse.julialang.org/t/hide-remove-replace-widgets-from-makie-jl-reactive-plots/106029 "2023-11-10T11:36:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliascarv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eliascarv/32/22152_2.png) [@eliascarv](https://discourse.julialang.org/u/eliascarv)\
**Post date:** [November 10, 2023, 11:36am UTC](https://discourse.julialang.org/t/hide-remove-replace-widgets-from-makie-jl-reactive-plots/106029/1 "2023-11-10T11:36:52Z")

</div>

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:

```julia
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

```
