# How to add a title to an existing plot?

**URL:** <https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [October 19, 2022, 11:24am UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956 "2022-10-19T11:24:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [October 19, 2022, 11:24am UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/1 "2022-10-19T11:24:27Z")

</div>

Hi all!

I’m doing some plots for a series of data. Since I needed to multiply two columns, and plot the output in a box plot, I came up with this:

```julia

adc_I_symbol = Symbol("Arc ADC Current (A)")
adc_V_symbol = Symbol("Arc ADC Voltage (V)")

usb_variations = boxplot(0, title="Powers (V*I)")
@df df_normal boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "sub_r5_r4_255")
@df df_normal_0 boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "sub_r5_r4_0")
@df df_normal_31 boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "add_r5_r4_31")
@df df_USB boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "sub_r5_r4_255 (USB)")
@df df_USB_0 boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "sub_r5_r4_0 (USB)")
@df df_USB_31 boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "add_r5_r4_31 (USB)")

```

So, basically I first create an empty plot, then I populate it with the data. However, **doing so won’t print the title**. I can add it on the last call:

```julia
@df df_USB_31 boxplot!(cols(adc_I_symbol) .* cols(adc_V_symbol), label = "add_r5_r4_31 (USB)", title = "Powers (V*I)")

```

or on every call, but it clutters the code or make it slightly worse to maintain. **Is there an idiomatic way to do this?** I read that for example I can do that in Makie, but maybe I’m missing a simpler solution.

Thanks

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [October 19, 2022, 1:31pm UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/2 "2022-10-19T13:31:00Z")

</div>

The following works for me

```julia
julia> using StatsPlots

julia> plot(; title = "Test")

julia> boxplot!([1,2,3], label="a")

julia> boxplot!([1,2,3], label="a")

```

```julia
pkg> st StatsPlots Plots
Status `~/.julia/environments/plots1.0/Project.toml`
  [91a5bcdd] Plots v1.35.4
  [f3b207a7] StatsPlots v0.15.4

```

---

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [October 19, 2022, 2:54pm UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/3 "2022-10-19T14:54:42Z")

</div>

It works, thanks! 🎊 🎉  
For curiosity, what does the semicolon do? Does it separate mandatory and optional arguments?

---

<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:** [October 19, 2022, 3:03pm UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/4 "2022-10-19T15:03:46Z")

</div>

This line should work too:  
` title!("My Title")`

---

<div class="post-metadata">

**Author:** ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Post date:** [October 19, 2022, 3:16pm UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/5 "2022-10-19T15:16:15Z")

</div>

That’s true, it works! 👍

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [October 19, 2022, 4:58pm UTC](https://discourse.julialang.org/t/how-to-add-a-title-to-an-existing-plot/88956/6 "2022-10-19T16:58:07Z")

</div>

That is correct, I typed it out of habit, should also work without.
