michiD
1
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
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?
couet
2
Form() is the answer.
mg->GetYaxis ()->SetTitle (Form("#splitline{%s}{m/s}",variable_name));
1 Like
couet
3
BTW, it seems you have an extra “}
” after velocity
michiD
4
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
mg->GetYaxis ()->CenterTitle ();
but that will only center the overall #splitline{}{}, not each line.
I_want.pdf (15.4 KB)
I_have.pdf (15.4 KB)
couet
5
No, there’s no control on that. Sorry.
You can just add spaces to approximate the centering, e.g.
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 
1 Like