Plot with Title on 2 lines - text centered

Hello,

Is there someone who knows a way to have title on 2 lines (text centered)?

My current trick is to use a fraction with Latex. Not very nice.

I want to try a gridbag with 3 lines (lines 1 & 2 to be 2x5% of height and line 3 would be 90%)
The idea is to use line 1 and 2 for the 2 line’s title

But I’m not getting there. Everything I have tried doesn’t do what I want.

anyone who can help me with the gridbag setup?

BR

Hello,

Can you be more precise ? You can already have a title with two lines of text by using a string matrix with two lines. The obtained box of text will be centered but inner alignment will be left justified:

plot([0 1],[0 1])
title(["two";"lines"])

Yes I can :slight_smile:

The example you are showing have the text aligned on the left

The example I’m attaching have the 2 lines centered

Command used:
“title(”$$\mathit{\frac{Title;long}{more;more;more;words}}$$“,“font_size”,7)”

BR
François

I have always loved plain TeX:

 plot(1:10,sin(1:10))
title("$\text{some text}\above 0pt \text{many many words}$","font_size",4)

Thank you.
That worked.
Sharing the code in case some are interested.

clc
clear
close()

x=linspace(0,10,1000)
y=sin(x)
z=cos(x)

f=figure("background",-2,"figure_position", [0 0],"figure_size",[1100 1000]);
drawlater()
    xgrid(-33,1,8)    
    plot(x,y,'color',ones(x)'*[1.0 0.0 0.0],'thickness',4)
    plot(x,z,'color',ones(x)'*[0.0 0.0 1.0],'thickness',4) 
    legend("$\textbf{\textit{Sin(x)}}$","$\textbf{\textit{Cos(x)}}$","107°C",-1)
    e=gce(),e.background=-2,e.font_size=5,e.font_style=8
    title("$\textbf{\textit{Some Text}}\above 0pt \textbf{\textit{many many words}}$","font_size",8)
    xlabel("$\textbf{\textit{Data}}$","font_size",7)
    ylabel("$\textbf{\textit{Result}}$","font_size",7)
    a=gca();a.zoom_box=[0.0 -1.2 max(x) 1.2];a.font_size=5;a.font_style=5
drawnow()

xs2svg(gcf(),"2_lines_centered.svg")
xs2png(gcf(),"2_lines_centered.png")