# How to retrieve axis handle from figure object?

**URL:** https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570
**Category:** Visualization
**Tags:** makie
**Created:** [June 10, 2022, 3:43pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570 "2022-06-10T15:43:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![hanshinlee77](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hanshinlee77/32/32867_2.png) [@hanshinlee77](https://discourse.julialang.org/u/hanshinlee77)
#### Post date: [June 10, 2022, 3:43pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/1 "2022-06-10T15:43:26Z")

</div>

Hello,

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?  
Thanks,  
Hanshin

---

<div class="post-metadata">

### Author: ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)
#### Post date: [June 10, 2022, 4:09pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/2 "2022-06-10T16:09:42Z")

</div>

```julia
using GLMakie

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

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

```

 ![figureaxes](https://global.discourse-cdn.com/julialang/original/3X/5/2/520b3cc6d0d5555326c6f21c63e0b14a219aec96.png)

---

<div class="post-metadata">

### Author: ![hanshinlee77](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hanshinlee77/32/32867_2.png) [@hanshinlee77](https://discourse.julialang.org/u/hanshinlee77)
#### Post date: [June 10, 2022, 4:32pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/3 "2022-06-10T16:32:24Z")

</div>

Great! thank you!

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [February 11, 2025, 4:33pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/4 "2025-02-11T16:33:23Z")

</div>

Should `fig.content` support `CartesianIndex`? It is very common to update the axis at position `[i,j]` in a grid layout.

---

<div class="post-metadata">

### Author: ![DanDeepPhase](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dandeepphase/32/24076_2.png) [@DanDeepPhase](https://discourse.julialang.org/u/DanDeepPhase)
#### Post date: [April 26, 2025, 4:14pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/5 "2025-04-26T16:14:36Z")

</div>

I’ve been wondering this for a while too. I found the answer in this video: [https://www.youtube.com/watch?v=L-gyDvhjzGQ](https://www.youtube.com/watch?v=L-gyDvhjzGQ)

this style allows selecting a certain plot:

```julia
ax1 = content(fig[1,1])
ax2 = content(fig[2,1])

```

also, need to use: `contents()` if there is multiple things at the figure position.

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [April 26, 2025, 5:51pm UTC](https://discourse.julialang.org/t/how-to-retrieve-axis-handle-from-figure-object/82570/6 "2025-04-26T17:51:53Z")

</div>

Yeah `fig.content` is just a way to keep track of the `Block`s in the figure in the order they were created in. The layouts themselves store the arrangement and as layouts are not matrices, there’s also no matrix storage anywhere.
