[R] two line plot title with expression problem
Uwe Ligges
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.
>
> x<-seq(-5,5,length=100)
> f<-function(x) x^2-x-1
>
>
> For a one line title the following works fine—
>
> plot(x,f(x),type="l")
> title(expression(paste("Golden Section ",fn:(phi^2-phi-1)),sep=""))
>
> but when attempting a two line title as follows--
>
> plot(x,f(x),type="l")
> 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:
plot(1:10)
title("Golden Section", line=3)
title(expression(fn:(phi^2-phi-1)), line=2)
or for left-adjustment, try the same with calls to mtext() and
specifying arguments "adj" and "at".
Uwe Ligges
> Thanks for help.
>
>
> John.
>
> [John Wilkinson : wilks at dial.pipex.com]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list