How to retrieve axis handle from figure object?


I have a function that creates a Makie (CairoMakie) plot and returns its figure object.
Occasionally, I need to modify some of the figure settings (e.g. axis limits) after this function is executed and the figure object is returned to REPL, but don’t want to pass them as input arguments to this plotting function. The returned figure object may contain multiple axes and I just can’t figure out how to get the handle to a specific axis from the figure object. There must be a straightforward way to do this, right?

using GLMakie

fig = Figure()
ax = Axis(fig[1,1])
plot!(ax, t, sin.(2π.*t))
plot!(ax, t, cos.(2π.*t))

# the axes can be accessed through the content member of the figure
ylims!(fig.content[1], -3, 3)

1 Like

Great! thank you!