Makie: swapping plots, un-hiding decorations, loading existing plot objects into axes

I am making a toggle (or later, a menu) that swaps a subplot for a totally different plot in the same space e.g. fig[1:2, 3:4].

Say I predefine two Axes objects, ax2a and ax2b with their x and y tick properties and labels. I first want to see ax2a so I hidedecorations!(ax2b) and empty!(ax2b) if needed and create a s2a = scatter!(ax2a,x,y; parameters)

Now I switch the toggle, it will trigger a function to swap the axes, and another to make the plot, e.g. s2b = lines!(ax2b, a,b; parameters). To swap the axes, I repeat the previous step, for ax2a. Now I need to activate the ax2b I previously “un-decorated”, but there seems to be no function to do that. The ax2b object is still alive, but should I then just redefine the axis and all its properties with the full Axes command? Or re-assign several of its internal properties? And, can I reload an already made plot object into its original axis, or even another axis?

The Axis object has a lot of visible properties which toggle what is shown and what not. The hidedecorations! and hidespline functions are mainly helper functions to set these properties.
This is a helper function which toggles these visibility properties and then you can use this to hide an Axis from a figure.
This also uses the visible property of all plots in the axis to hide them.

function visible!(ax::Axis, makevisible=false)
    # Spines
    ax.bottomspinevisible = makevisible
    ax.leftspinevisible = makevisible
    ax.rightspinevisible = makevisible
    ax.topspinevisible = makevisible

    ax.subtitlevisible = makevisible
    ax.titlevisible = makevisible
    
    ax.xgridvisible = makevisible
    ax.xticksvisible= makevisible
    ax.xticklabelsvisible = makevisible
    ax.xlabelvisible = makevisible
    ax.xminorgridvisible = makevisible
    ax.xminorticksvisible = makevisible

    ax.ygridvisible = makevisible
    ax.yticksvisible= makevisible
    ax.yticklabelsvisible = makevisible
    ax.ylabelvisible = makevisible
    ax.yminorgridvisible = makevisible
    ax.yminorticksvisible = makevisible

    # Make all plots in ax visible

    for p in ax.scene.plots
        p.visible = makevisible
    end
end

In principle it’s easier to do ax.blockscene.visible[] = false and ax.scene.visible[] = false to hide everything visual. The problem is that this doesn’t do anything about the events going to - and possibly consumed by - the axis. So if you layer two of them on top of each other, the first one is still going to receive all the events even if the scenes are invisible. I wonder if that behavior should be changed.

Yes, I have a click/zoom event in one of the plot types.

I guess my original thought was that I could keep plots alive in each axis, perhaps even updating when not shown, and then use the toggle to display (hide/unhide) one of them. Indeed the event interaction particular to the plots types should also be swapped.

That seems to require two axes, so maybe the ax.blockscene visibility along with disabling/enabling certain interactions could work i.e. a mouse click would take the location in the current active axis that has the interaction enabled?

Does updating a plot in an invisible axis, e.g. with a scatter! command, make it visible again?