Inset axis in Makie

How to make the inset axis non-transparent?

using CairoMakie
f = Figure()
ax1 = Axis(f[1,1])
scatter!(ax1, randn(1000), randn(1000))
ax2 = Axis(f[1,1], width=Relative(0.2), height=Relative(0.3), halign=0.1, valign=0.1, backgroundcolor=:white)
scatter!(ax2, randn(100), randn(100), color=:red)
save("test.png", f)

I usually do:

# bring content upfront
    translate!(ax2.scene, 0, 0, 10)
    elements = keys(ax2.elements)
    filtered = filter(ele -> ele != :xaxis && ele != :yaxis, elements)
    foreach(ele -> translate!(ax2.elements[ele], 0, 0, 9), filtered)

Layouts - Julia Data Science (last section)

This will probably get much easier relatively soon, when every object like Axis etc will have its own container scene which needs just one z translation forward. Or I make a convenience method for inset axes anyway.


@jules Do you have a branch already available… I would be interested in taking a look :smiley:

Yeah it’s this one GitHub - JuliaPlots/Makie.jl at jk/layoutables-refactor

Only Axis, Slider, Label and the new SliderGrid work so far (that one is a consolidation of what labelslidergrid! did before). It’s the ax.blockscene field that contains the Scene that you need to translate forward.