Re: [R] Fitting large titles in a plot

From: Marc Schwartz <>
Date: Thu, 06 Dec 2007 13:04:27 -0600

On Thu, 2007-12-06 at 07:16 -0800, Svempa wrote:
> I want to fit a fairly long main title for a plot, supposedly by changing row
> after a while. As for now it starts way outside the picture margin at the
> left and continues way out right passed the right margins.
> >plot(A,main="This is my really long title and it's so long that I can see
> just about half of it.")
> Any suggestions? Shouldn't be that hard.

You can insert newline characters ('\n') in the title:

plot(A, main = "This is my really long title\nand it's so long that I can see\njust about half of it.")

The likelihood is that you will need to alter the vertical position of the title to accommodate the line wrapping.

To do that, you can either use mtext() in lieu of the 'main' argument, or consider adjusting par("mgp"), the first value of which is the position of the plot title. See ?mtext and ?par.

You might also want to look at ?strwrap for a more general way of wrapping long lines of text.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 06 Dec 2007 - 19:13:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Dec 2007 - 19:30:18 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.