# Line Breaks in AxesLabel or PlotLabel?

Searching got me peripherally related threads, but not exactly what I was looking for.

I'm making some graphs which I want to use on exams. Sometimes, labels (specifically in AxesLabel and PlotLabel) that are longish can be a hassle. Is there a way to introduce a line break in these labels to make them fit better in the space that I have? Thanks in advance.

-
I get the feeling this question is probably a duplicate –  Mike Honeychurch Jul 25 '14 at 3:47

Try this:

Plot[Sin[2 x], {x, -Pi, Pi},
AxesLabel -> {"This is\n an axes label", None}]


And here's the same using FrameLabel instead of AxesLabel.

Plot[Cos[2 x], {x, -Pi, Pi}, Frame -> True,
FrameLabel -> {{"This is\n a y frame label",None},
{"This is\n an x frame label", None}}]


This is covered in the documentation under Newlines and Tabs in Strings.

And if you want more control, you can even use Columns and Grids:

Plot[Cos[2 x], {x, -Pi, Pi}, Frame -> True,
FrameLabel -> {{Column[{"Column1", "Column2"}], None},
{Grid@{{1, 2}, {3, 4}}, None}}]


-
I tried \n but it just shows up in the label that way, no line break. Am I missing something? –  Zippy The Pinhead Jul 25 '14 at 19:06
I notice that imposing formatting on the text seems to be the cause. But thanks! –  Zippy The Pinhead Jul 25 '14 at 19:12

An alternative to manually setting line breaks is to set a label size and then let the label break as needed:

Plot[Cos[2 x], {x, -Pi, Pi}, Frame -> True,
FrameLabel -> {{Pane["This is a y frame label", {50, All}],
None}, {Pane["This is an x frame label", {50, All}], None}}]


-
Why 50 and not 45 (which gives the same result) ? Why 45 and not 20 ? –  eldo Jul 25 '14 at 0:51
@eldo why not 55, why not 150, why not 126, why not 87. the whole point is to choose whatever label size you want. If you like 20 then choose 20. –  Mike Honeychurch Jul 25 '14 at 1:11
BTW I think this Q&A is probably a duplicate –  Mike Honeychurch Jul 25 '14 at 3:46