6

I want to split xlabel into lines. My MWE is below:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
       % xlabel = Temp, $N$ \newline Slice at X
        xlabel = Temp $N$ \newline Slice at X        
        , ylabel = $P$
        , zlabel = Response
        , xmin = -1
        , xmax = 1
        , ymin = -1
        , ymax = 1
        %, x dir = reverse
        , view={-40}{30}]
   \addplot3
   [
    surf
   ,  faceted color=blue
   , samples  = 15
   , domain   = -1:1
   , y domain = -1:1
   ]
    {56+ 1* x + 2* y + 3*x*y};
    \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

I wonder how to split xlabel into two lines and also how to put comma (,) in the xlabel. Thanks

1 Answer 1

6

xlabel is printed as node. So you can set a specific text width. This allows line breaks. The modification can be done by the option xlabel style. An example is shown in the documentation on page 173:

xlabel style={align=right,text width=3cm}

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
       % xlabel = Temp, $N$ \newline Slice at X
        xlabel style={draw,rectangle,align=left,text width=2cm},
        xlabel = Temp $N$ \newline Slice at X        
        , ylabel = $P$
        , zlabel = Response
        , xmin = -1
        , xmax = 1
        , ymin = -1
        , ymax = 1
        %, x dir = reverse
        , view={-40}{30}]
   \addplot3
   [
    surf
   ,  faceted color=blue
   , samples  = 15
   , domain   = -1:1
   , y domain = -1:1
   ]
    {56+ 1* x + 2* y + 3*x*y};
    \end{axis}
\end{tikzpicture}

\end{document}
2
  • Thanks @Marco for your answer. Could you help me how to put comma (,) after Temp and before N. Thanks
    – MYaseen208
    Commented May 19, 2013 at 7:43
  • put the value of xlabel into brackets: xlabel = {Temp, $N$ \newline Slice at X}. This normally recommended for all values which contains spaces or other symbols like your comma. Commented May 19, 2013 at 7:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .