# Variable Title - Mutiple Lines

**URL:** <https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625>\
**Category:** Newbie\
**Created:** [February 1, 2022, 1:37pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625 "2022-02-01T13:37:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![michiD](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@michiD](https://root-forum.cern.ch/u/michiD)\
**Post date:** [February 1, 2022, 1:37pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/1 "2022-02-01T13:37:37Z")

</div>

_Platform:_ Linux / C++  
_Compiler:_ Clang

* * *

Hello,  
I want label my y-axis with multiple lines.  
For example  
first line = velocity  
second line = m/s  
I use

```auto
   mg->GetYaxis ()->SetTitle (
          ("#splitline{velocity}}{m/s}"));

```

Which works. But I want to use variable names and units.  
So if I call the function again, I might want to use e.g. {acceleration}{m/s^2}

How can I use variable input for the #splitline command?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 1, 2022, 1:44pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/2 "2022-02-01T13:44:35Z")

</div>

Form() is the answer.

```auto
mg->GetYaxis ()->SetTitle (Form("#splitline{%s}{m/s}",variable_name));

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 1, 2022, 2:56pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/3 "2022-02-01T14:56:56Z")

</div>

> [@michiD](#):
>
> ```auto
> mg->GetYaxis ()->SetTitle (
> ("#splitline{velocity}}{m/s}"));
> 
> ```

BTW, it seems you have an extra “`}`” after `velocity`

---

<div class="post-metadata">

**Author:** ![michiD](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a9a28c/32.png) [@michiD](https://root-forum.cern.ch/u/michiD)\
**Post date:** [February 2, 2022, 3:53pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/4 "2022-02-02T15:53:39Z")

</div>

Thanks it works.  
One more kind of related question.

If I use the #splitline{}{} those two lines will not be centered, but left-aligned (“linksbündig”)  
Is there a way to center-align them.

I already use

```auto
      mg->GetYaxis ()->CenterTitle ();

```

but that will only center the overall #splitline{}{}, not each line.  
[I\_want.pdf](https://root-forum.cern.ch/uploads/short-url/mJlCR6L3XT5CYkp4CxK2ul0lT37.pdf) (15.4 KB)  
[I\_have.pdf](https://root-forum.cern.ch/uploads/short-url/oquZqGBj8vxVpTB52C4qFHVO6JG.pdf) (15.4 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 2, 2022, 4:36pm UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/5 "2022-02-02T16:36:46Z")

</div>

No, there’s no control on that. Sorry.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [February 3, 2022, 4:58am UTC](https://root-forum.cern.ch/t/variable-title-mutiple-lines/48625/6 "2022-02-03T04:58:58Z")

</div>

You can just add spaces to approximate the centering, e.g.

```auto
  mg->GetYaxis()->SetTitle(Form("#splitline{%s}{ m/s}","velocity"));

```

(3 spaces in this case)  
It needs some trial and error and won’t be perfect, but close enough 🙂
