# Editing titles after creating a Makie plot

**URL:** <https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [August 13, 2021, 4:46pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352 "2021-08-13T16:46:56Z")\
**Posts on this page:** 7\
**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 13, 2021, 4:46pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/1 "2021-08-13T16:46:56Z")

</div>

I’m customizing `Makie.plot` to edit axis properties due to [Accessing axis in Makie plot recipes](https://discourse.julialang.org/t/accessing-axis-in-makie-plot-recipes/66006). My function looks something like this:

```julia
function foo(fig = Makie.Figure())
  axes = [Makie.Axis(fig[i,j]) for j in 1:3, i in 1:2]
  for (i, ax) in enumerate(axes)
    Makie.scatter!(ax, randn(10))
    ax.title = "Plot number $i"
  end
  fig
end

```

I’d like users to be able to edit the plot afterwards (like adding or remove titles). Is there a recommended way to do this?

I wasn’t sure how to recover `axes` from the return argument `fig`. I thought maybe I should return a `Makie.FigureAxisPlot` instead so that there is a way to access the `axis`, but I wasn’t sure how to specify the `plot` field.

---

<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 13, 2021, 9:44pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/2 "2021-08-13T21:44:27Z")

</div>

No recommended way, you can return the axes in a tuple with the Figure if they’re important, otherwise you could theoretically still get at them via the `content` function for example.

---

<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 13, 2021, 10:06pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/3 "2021-08-13T22:06:17Z")

</div>

Thanks for the tip on `content`. However, `fig.content` is a vector instead of a matrix, and I’d like to pass the latter to users if possible since the layout is more intuitive.

If I return `fig, axes` in a tuple, the plot doesn’t pop up. I’d like to be able to call `foo()` to have the plot appear, but also return a configurable plot object. That’s why I was thinking of returning `FigureAxisPlot` - it returns axis information but also makes the plot pop up. However, I’m not sure what to provide for the `plot` field here.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 13, 2021, 11:19pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/5 "2021-08-13T23:19:20Z")

</div>

This seems to work:

```julia
using GLMakie

function foo(fig = Makie.Figure())
    axes = [Makie.Axis(fig[i,j]) for j in 1:3, i in 1:2]
    for (i, ax) in enumerate(axes)
      Makie.scatter!(ax, randn(10))
      ax.title = "Plot number $i"
    end
    display(fig)
    fig, axes
end

fig, axesv = foo()

axesv[1].title = "Hello No.1 !"
axesv[5].title = "Hello No.5 !"

```

---

<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 13, 2021, 11:30pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/6 "2021-08-13T23:30:40Z")

</div>

Yes, but it then requires typing `fig` to actually display the plot. I’d like to have `foo()` both display the figure, and also return axis information.

What Makie command does typing “fig” actually call to show the figure? I think I could wrap `fig` and `axes` in a custom type and overload the “show figure” command.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 13, 2021, 11:32pm UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/7 "2021-08-13T23:32:39Z")

</div>

Just add: `display(fig)` before returning the axes ?

_NB: edited code above accordingly_

---

<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 14, 2021, 12:05am UTC](https://discourse.julialang.org/t/editing-titles-after-creating-a-makie-plot/66352/8 "2021-08-14T00:05:48Z")

</div>

I didn’t know that worked…thanks!
