# Adding arbitrary text to Plots.jl output

**URL:** <https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262>\
**Category:** General Usage\
**Tags:** plotting, plots\
**Created:** [January 2, 2024, 1:42pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262 "2024-01-02T13:42:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulmelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulmelis/32/35063_2.png) [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Post date:** [January 2, 2024, 1:42pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262/1 "2024-01-02T13:42:45Z")

</div>

I’d like to add some footer text to my plots (I’m already using two lines of `title`), but can’t seem to find a way to do it. I know about `annotate!()`, but that only adds text _within_ the plot region in the plot coordinate system, while I’d like to add text at arbitrary pixel locations in the output image. Is there any support for this in Plots.jl? Alternatively, is there a way to get the image pixels of a plot directly, without having to save first?

---

<div class="post-metadata">

**Author:** ![paulmelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulmelis/32/35063_2.png) [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Post date:** [January 2, 2024, 2:58pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262/3 "2024-01-02T14:58:02Z")

</div>

So indeed I can place annotations in the plot margin. But it’s still a bit tricky to get good label positioning, as the area containing axis ticks and labels needs to be skipped and I haven’t found a way to get their width/height yet.

---

<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:** [January 2, 2024, 3:02pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262/4 "2024-01-02T15:02:24Z")

</div>

For better control of the area dedicated to your bottom labels, you can use Plots.jl layouts.

---

<div class="post-metadata">

**Author:** ![paulmelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulmelis/32/35063_2.png) [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Post date:** [January 2, 2024, 3:35pm UTC](https://discourse.julialang.org/t/adding-arbitrary-text-to-plots-jl-output/108262/5 "2024-01-02T15:35:26Z")

</div>

Thanks for the tip! After a bit of fiddling I’m quite happy with this result:

```julia
using Plots
data = rand(4, 50)

l = @layout [a{0.98h} ; b]
p = heatmap(data, title="Title\nsubtitle", margin=1Plots.cm, yflip=true)

p2 = plot(axis=([], false), margin=0Plots.cm)
ftr = text("My footer containing blabla...", :black, :right, 8)
annotate!(1, 0.5, ftr)

plot(p, p2, layout=l, size=(960,540))

```

 ![doh](https://global.discourse-cdn.com/julialang/original/3X/4/1/411b8588680cca6fe0f10924b172a1af9261f17d.png)
