# Accessing axis in Makie plot recipes

**URL:** <https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006>\
**Category:** Visualization\
**Tags:** makie, recipe\
**Created:** [August 8, 2021, 1:51am UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006 "2021-08-08T01:51:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [August 8, 2021, 1:51am UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/1 "2021-08-08T01:51:50Z")

</div>

Is there a way to access the axis in a Makie plot recipe? I’d like to apply `xlims!(ax, ...)` and set `ax.aspect = ....`.

---

<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:** [August 8, 2021, 5:56am UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/2 "2021-08-08T05:56:36Z")

</div>

Not yet, no. This is one part of the ongoing refactor of plot types and recipes, because when they were written there was no Axis.

---

<div class="post-metadata">

**Author:** ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)\
**Post date:** [August 9, 2021, 5:09am UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/3 "2021-08-09T05:09:01Z")

</div>

What about just applying a theme to the Axis, not a full programmatic access to it? For instance, I was hoping that in this recipe the newly created Axis would have a certain background color, etc, but it seems the theme information was not used in any way.

```julia
struct TestStruct
    data
end

ts = TestStruct([1,2,3])

@recipe(TestRecipe) do scene
    Theme(
    Axis = (
        backgroundcolor = :gray90,
        leftspinevisible = false,
        rightspinevisible = false,
        bottomspinevisible = false,
        topspinevisible = false,
        xgridcolor = :white,
        ygridcolor = :white,
    )
    )
end

function Makie.plot!(tr::TestRecipe{<:Tuple{TestStruct}})
    data = tr[1][].data
    scatter!(tr, data, data*2)
    tr
end

testrecipe(ts)

```

---

<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:** [August 14, 2022, 9:17pm UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/4 "2022-08-14T21:17:33Z")

</div>

@jules any update on this refactor of the recipe system to allow for more customization of the axis, the legend, the subplots in a layout, etc?

---

<div class="post-metadata">

**Author:** ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)\
**Post date:** [September 11, 2024, 3:06pm UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/5 "2024-09-11T15:06:24Z")

</div>

Any updates here? I want to customize the title of the plot since the info is embedded in the struct I want to plot.

---

<div class="post-metadata">

**Author:** ![Jeff\_Wack](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@Jeff\_Wack](https://discourse.julialang.org/u/Jeff_Wack)\
**Post date:** [November 24, 2024, 9:18am UTC](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006/6 "2024-11-24T09:18:18Z")

</div>

In regards to setting the axis limits, one can call

> limits!(x1, x2, y1, y2)

or

> xlims!(x1, x2)

from within the definition of Makie.plot!(myplot::MyPlot) and it successfully sets the axis limits.
