[R] Fitting large titles in a plot
Marc Schwartz
marc_schwartz at comcast.net
Thu Dec 6 20:04:27 CET 2007
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
More information about the R-help
mailing list