Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My pgfplots ylabel text is too long and looks strange. Can I make it multiline?

share|improve this question
add comment

1 Answer

up vote 18 down vote accepted

The ylabel can be adjusted like other nodes. The key you can use for this is ylabel syle={<options>}.

To make it multiline, you can either just provide a text alignment option, using align=<center/left/right/justify>, and then insert the line breaks manually with \\.

The second option is to provide a text width that the text should keep to, using text width=<width>, and it will automatically wrap around. By default, the text will be left aligned, but you can use the align key here, too.

\documentclass{minimal}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=6cm,
ylabel style={align=center}, ylabel=A very long\\long\\text as a label,
xlabel style={text width=2.5cm}, xlabel=This is a long xlabel]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}

pgfplots plot with multiline labels

share|improve this answer
    
Thanks again. :) –  shino Apr 20 '11 at 13:41
    
@Jake Did anything change since you posted your answer? I get an error-message saying: "I do not know the key '/tikz/align' and I am going to ignore it." –  John Oct 25 '12 at 23:55
1  
@John: That sounds like you're using a very old version of TikZ. The current version is 2.1, you're probably using 2.0 (which is several years old). –  Jake Oct 26 '12 at 9:10
    
@Jake This is odd because I downloaded TeXShop (Version 2.47) a couple of month ago. Why should the package include an outdated distribution? –  John Oct 26 '12 at 13:52
1  
@John: Okay, so you've got an outdated version of TeX Live and TikZ. The best thing to do what probably be to install TeX Live 2012. Alternatively, you could just update the TikZ package. –  Jake Oct 26 '12 at 14:26
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.