[R] two line plot title with expression problem
ligges at statistik.uni-dortmund.de
Fri Feb 25 18:34:33 CET 2005
John Wilkinson (pipex) wrote:
> 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?
Multi-line expressions are not supported. You can add them by separate
calls to title(), though:
title("Golden Section", line=3)
or for left-adjustment, try the same with calls to mtext() and
specifying arguments "adj" and "at".
> Thanks for help.
> [John Wilkinson : wilks at dial.pipex.com]
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help