# Left-aligned PlotLabel?

Is it possible to have the text generated by PlotLabel (or any other function) aligned to the left side of the plot instead of in the center?

-

 Labeled[Plot[Sinc[x], {x, 0, 9}], Style["plot label", "Section"], {{Top, Left}}]


-
This is exactly what I was looking for. –  Matthew Apr 16 '13 at 19:01

You can specify your PlotLabel to be a construct that takes a TextAlignment or Alignment option, such as Pane. For example:

Plot[Sin[x], {x, 0, 5},
PlotLabel -> Framed@Pane["This is the title", Alignment -> Left,
ImageSize -> 270], ImageSize -> 300]


The Framed isn't necessary; I just included it so you could see what was going on.

The main trick is that you need to specify the size of both the total graphic and the Pane, so that the text will align to the left edge of the graphic or the axis, as shown here.

If you don't do it this way, the Pane will indeed be left-aligned text, but it will "shrink" to fit the text and still be aligned center, like this:

Plot[Sin[x], {x, 0, 5},
PlotLabel -> Framed@Pane["This is the title", Alignment -> Left]]


As an alternative, you can bend AxesLabel to fit, by working out how wide the label will be in pixels, and then adding that amount of spacing to its left in a Row construct to make the argument to AxesLabel. This is similar in spirit to Mr.Wizard's answer but has the advantage of automation of the spacing.

With[{space =
Plot[Sinc[x], {x, 0, 10}, AxesLabel -> Row[{Spacer[space], Sinc[x]}] ]]


Obviously if you have styled the label for the plot label in some other way, you will need to adjust the argument to Rasterize accordingly.

-
Nice. For some reason I didn't think Pane worked. +1! –  Mr.Wizard Apr 7 '13 at 5:06

You can use Epilog to insert the plot label wherever you wish within the PlotRange.

Edit: There is a drawback to this approach. Because the title will be within the graph region, there is a possibility that the title will be appear over part of the graph of the function.

Plot[Sinc[x], {x, 0, 9},
Epilog -> Text[Style["This is where my plot label goes", {Blue, 16}],
Offset[{30, -10}, Scaled[{0, 1}]], {-1, 0}]]


In the example, the text, the title is offset 30 printer's points (30/72 in) to the right and 10 printers points (10/72 in) under the upper left corner (Scaled[{0,1}]) of the Graphic. It is left-justified, {-1,0}.

-

Not directly that I am aware of. You could of course fake it with spacing:

Plot[Sinc[x], {x, 0, 9}, PlotLabel -> Row@{"Text", Spacer[300]}]


Simpler may be use Column but it is not part of the Graphics object itself:

Column@{"Text", Plot[Sinc[x], {x, 0, 9}]}

-
I need the label to be part of the Graphics object. The spacing option isn't very dynamic. I guess there's no "easy" way to do it. –  Matthew Apr 7 '13 at 0:10
@Matthew Fortunately there is, and I was merely ignorant. See Verbeia's answer. :-) –  Mr.Wizard Apr 7 '13 at 5:07