# Makie: add title to plot

**URL:** https://discourse.julialang.org/t/makie-add-title-to-plot/22340
**Category:** General Usage
**Created:** [March 26, 2019, 9:35am UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340 "2019-03-26T09:35:45Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)
#### Post date: [March 26, 2019, 9:35am UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/1 "2019-03-26T09:35:45Z")

</div>

How to add a title to a `Makie` plot? I would to produce a plot like the following using Makie instead of Plots.jl:

```julia
julia> using Plots; plot(randn(10), title="my random numbers")

```

![grafik](https://global.discourse-cdn.com/julialang/original/3X/5/9/597964bf6db91fc72956763667c2e76ccdef55ce.png)

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [March 26, 2019, 11:42am UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/2 "2019-03-26T11:42:14Z")

</div>

This will need some better integration, but this works:

```julia
using Makie

theplot = lines(randn(10))

pos = lift(pixelarea(theplot)) do area
    x = widths(area)[1] ./ 2
    Vec2f0(x, 10) # offset 10px, to give it some space
end
title = text(
    "my random numbers", align = (:center, :bottom), 
    position = pos, camera = campixel!, raw = true, textsize = 40, # in pixel,
)
hbox(theplot, title)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/2/f217f297795224e79ad0c764f437109d6b0d556c.png)  
Could probably be put in a `title` function…

---

<div class="post-metadata">

### Author: ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)
#### Post date: [September 4, 2019, 6:40pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/3 "2019-09-04T18:40:34Z")

</div>

Just because this is a first result in a google search, I wish to point out that currently (09/04/2019) there is a title function:

```julia
using Makie

theplot = lines(randn(10))
sc = title(theplot,"Title")

```

---

<div class="post-metadata">

### Author: ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)
#### Post date: [September 9, 2019, 6:54pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/4 "2019-09-09T18:54:32Z")

</div>

> [@aramirezreyes](#):
>
> ```julia
> sc = title(theplot,"Title")
> 
> ```

Yep, that’s actually an implementation of Simon’s suggestion here 😃

---

<div class="post-metadata">

### Author: ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)
#### Post date: [September 9, 2019, 9:50pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/5 "2019-09-09T21:50:18Z")

</div>

Yeah, I noticed that, but the actual existence of that implementation took longer to find.  
I thought It was worth it to mention it in this topic that has higher visibility than other thing, right?

---

<div class="post-metadata">

### Author: ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)
#### Post date: [August 10, 2020, 6:46pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/6 "2020-08-10T18:46:26Z")

</div>

Anyone notice this title doesn’t work for 3D plots?

---

<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: [June 1, 2021, 9:31pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/7 "2021-06-01T21:31:20Z")

</div>

FWIW, [Makie: add title to plot - #3 by aramirezreyes](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/3) no longer works. Three other options:

1. [https://makie.juliaplots.org/dev/makielayout/axis.html#Creating-an-Axis](https://makie.juliaplots.org/dev/makielayout/axis.html#Creating-an-Axis)
2. `plt = scatter(randn(10), axis = (title = "my title",))`
3. `f, ax, s = scatter(...); ax.title = "my title"`

---

<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: [June 1, 2021, 9:38pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/8 "2021-06-01T21:38:59Z")

</div>

or a manually created axis with `Axis(fig[1, 1], title = "my title")`. Or if there’s an object you want to give a title even though it doesn’t have an attribute like that, you can place a label in the upper protrusion of the layout cell. For example, to give a slider a title (doesn’t make sense but anyway):

```julia
f = Figure()
Slider(f[1, 1])
Label(f[1, 1, Top()], "a title", padding = (0, 0, 10, 0))

```

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [June 1, 2021, 9:39pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/9 "2021-06-01T21:39:00Z")

</div>

```julia
fig[0, :] = Label(fig, "my title")

```

works for me.

---

<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: [June 1, 2021, 9:39pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/10 "2021-06-01T21:39:43Z")

</div>

Yes this one is very useful for super titles or section titles

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [June 7, 2021, 8:21pm UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/12 "2021-06-07T20:21:47Z")

</div>

Is there a declarative way to add a supertitle? The issue I face with

```julia
figuregrid = draw(spec)
figuregrid.figure[0, :] = Label(figuregrid.figure, "my title")

```

is that re-running that line adds an additional title on top. I would like an idempotent command that I can run without worrying about execution order or multiplicity.

---

<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: [June 8, 2021, 5:33am UTC](https://discourse.julialang.org/t/makie-add-title-to-plot/22340/13 "2021-06-08T05:33:45Z")

</div>

Not really, because in my philosophy there is not really just one type of super title, at least with the flexible layout model there is no “slot” that could be reserved for the super title. I guess one could add a separate title to the figure that pushes down its internal grid layout, instead of being added to it, and that would enable an idempotent supertitle command. But I’m not sure that adding this complexity gains so much
