[Tex/LaTex] PGFPlots: can a forced line break be added in the title command

tikz-pgf

I have a some data plotted with pgfplots. I would like to make the title two lines. Can this be done? I tried adding \\ in the title command but that did nothing. Additionally, I couldn't find anything in the manual.

In my axis command, I have the option title = {text \\ text} where I want to split the title.

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[title = {text \\ text}]
\addplot[smooth, samples = 100, domain = 0:2] (\x, 2);
\end{axis}
\end{document}

Best Answer

Add align=center does the trick:

enter image description here

Code:

\documentclass[tikz, border=2pt]{standalone}
\usepackage{pgfplots}
%\pgfplotsset{compat = 1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[align =center, title = {text \\ text}]
\addplot[smooth, samples = 100, domain = 0:2] (\x, 2);
\end{axis}
\end{tikzpicture}
\end{document}