# How to make a plot with multiple titles and labels in Makie

**URL:** <https://discourse.julialang.org/t/how-to-make-a-plot-with-multiple-titles-and-labels-in-makie/89137>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 23, 2022, 10:51am UTC](https://discourse.julialang.org/t/how-to-make-a-plot-with-multiple-titles-and-labels-in-makie/89137 "2022-10-23T10:51:12Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [October 23, 2022, 10:51am UTC](https://discourse.julialang.org/t/how-to-make-a-plot-with-multiple-titles-and-labels-in-makie/89137/1 "2022-10-23T10:51:12Z")

</div>

Question from Slack, posting here to keep the solution searchable in the future:

> This is a figure from IMF blog. Is it possible to create a plot like this: Have title and a write up in the top and caption at the bottom

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/3/8322498ebbb7d2588dc28a7d01cb1eab06a0ab67.jpeg)

Here’s my attempt to make something similar in Makie.jl. Because there are three levels of title, I did this with an extra GridLayout but in the future, one will probably be able to change fonts within strings and just use `title` and `subtitle` attributes for this directly:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/a/baa604220e0434abc91db02958bdfd9d02520407.png)

```julia
using CairoMakie
using Random
Random.seed!(1234)

x = range(2007, 2035, length = 1000)

function randdata(n)
    data = cumsum(randn(1000))
    data .-= range(first(data), last(data), length = 1000)
    data .* 0.1
end
euro = randdata(1000)
japan = randdata(1000) .+ 1
uk = randdata(1000) .- 2
emerging = randdata(1000) .- 6

f = Figure()
ax = Axis(f[1, 1], xgridvisible = false, ygridvisible = false, xticksvisible = false, alignmode = Outside(), xticks = 2007:4:2031, ytrimspine = true, 
    palette = (; color = [:deepskyblue, :firebrick3, :dodgerblue4, :goldenrod1]))

hidespines!(ax, :b, :t, :r)
hlines!(ax, 0, color = :black, linewidth = 1)

for (label, data) in ["Euro" => euro, "Japan" => japan, "UK" => uk, "Emerging markets" => emerging]
    lines!(ax, x, data; label, linewidth = 2)
end

titlelayout = GridLayout(f[0, 1], halign = :left, tellwidth = false)
Label(titlelayout[1, 1], "Interest rate differentials", halign = :left, textsize = 30, font = "TeX Gyre Heros Bold Makie")
Label(titlelayout[2, 1], "Differences in monetary policy are a key driver of the strong dollar.", halign = :left, textsize = 20)
Label(titlelayout[3, 1], "(versus US interest rate, percent)", halign = :left)
rowgap!(titlelayout, 0)

for (label, (year, y)) in ["Global\nfinancial\ncrisis" => (2008, 8), "Taper\ntantrum" => (2013, 8), "China\n2015\ncrisis" => (2015.4, 6), "Russia invasion\nof Ukraine" => (2022.1, 8)]
    lines!(ax, [year, year], [-10, y], color = :black, linestyle = :dash)
    text!(ax, year, y, text = label, align = (:left, :top), offset = (10, 0), textsize = 14)
end

ylims!(ax, -11, 11)
xlims!(ax, 2007, 2035)

axislegend(position = (0.5, 1.05), orientation = :horizontal,
    framevisible = false)

Label(f[2, 1], """
Sources: Bloomberg Finance L.P.; Haver Analytics; and IMF staff calculations.
Notes: Differential is calculated as US overnight bank funding rate minus foreign
inter-bank rate. The dots depict the forward paths for nominal interest rates.
""", tellwidth = false, halign = :left, justification = :left)

f

```

---

<div class="post-metadata">

**Author:** ![jerlich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jerlich/32/5205_2.png) [@jerlich](https://discourse.julialang.org/u/jerlich)\
**Post date:** [October 25, 2022, 11:14am UTC](https://discourse.julialang.org/t/how-to-make-a-plot-with-multiple-titles-and-labels-in-makie/89137/2 "2022-10-25T11:14:19Z")

</div>

can this be added to beautiful makie?

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [October 29, 2022, 12:58pm UTC](https://discourse.julialang.org/t/how-to-make-a-plot-with-multiple-titles-and-labels-in-makie/89137/3 "2022-10-29T12:58:05Z")

</div>

now it will be 😄
