[R] two line plot title with expression problem

John Wilkinson (pipex) wilks at dial.pipex.com
Fri Feb 25 15:35:24 CET 2005

Dear R-users,

I am having a problem formatting a two line plot title with the first line
text and the second line an expression. I can’t get the second line
expression to line up with the first by starting at the LHS of the line.

A simple example illustrates the situation.

f<-function(x) x^2-x-1

For a one line title the following works fine—

title(expression(paste("Golden Section  ",fn:(phi^2-phi-1)),sep=""))

but when attempting a two line title as follows--

title(expression(paste("Golden Section\n  ",fn:(phi^2-phi-1)),sep=""))

the second line containing the expression for phi is indented,
to the right, starting immediately after the position of the end
letter of the first line.

If the second line were to be text, this would not be a problem.

How can I format the title so that the expression starts immediately under
the first line?

Thanks for help.


[John Wilkinson : wilks at dial.pipex.com]

More information about the R-help mailing list