Add title to Makie plot and maintain previous scene settings

I have:

  using Makie

  scene = Scene(resolution = (1200, 1400))
  lines!(scene, randn(10))
  # display(scene)
  display(title(scene, "Title"))

which changes the resolution compared to using just display(scene). What is the way to preserve previous scene settings?

axis = scene[Axis]
axis.names.title = "My Title"

Thank you. It works for plots with axes. Is there a more general form, which would work in this case too?

using AbstractPlotting, GLMakie, Random

image = rand(1:4, 64, 48)
scene = Scene(resolution = (1200, 1000))
image!(scene, image, scale_plot = false, show_axis = false, interpolate = false, colormap=[:white, :blue, :green, :red])
axis = scene[Axis]
axis.names.title = "My Title"
display(scene)
.....
ERROR: LoadError: type Nothing has no field names

It seems that MakieLayout.jl could help for what you need:

using MakieLayout, AbstractPlotting
using Random

outer_padding = 30
scene, layout = layoutscene(outer_padding, resolution = (1200, 1000));
ax1 = layout[1, 1] = LAxis(scene, title = "My Title")

image = rand(1:4, 64, 48);
image!(ax1, image, scale_plot = false, show_axis = false, interpolate = false, colormap=[:white, :blue, :green, :red])
tightlimits!.(ax1)
hidedecorations!.(ax1)
display(scene)

PS: As a word of caution, I am a Julia beginner and it seems hard to keep track of all the packages needed to do something. In case of Makie there are several in the GLMakie, MakieLayout, AbstractPlotting, etc…

NOTE: according to MakieLayout.jl’s github page, it has been absorbed by AbstractPlotting, which sounds good.

Thank you. MakieLayout is indeed a more flexible way of doing it. I don’t like that it ignores show_axis parameter in:

image!(ax1, image, scale_plot = false, show_axis = false, interpolate = false, colormap=[:white, :blue, :green, :red])