[R] Greek letters on a multi-line plot title
David Scott
d.scott at auckland.ac.nz
Thu Jan 21 01:50:44 CET 2010
Jason Rupert wrote:
> David,
>
> Thank you very much for your response.
>
> Is there any chance you can provide your example where mtext is used?
>
> I also tried to use mtext, but I did not have any luck, so any help with the example below working with mtext or otherwise is greatly appreciated.
>
> Thanks again,
> Jason
>
>
This code works for me and should give the general idea. It is taken
from code I use for testing in one of my packages.
### Change spacing to allow for multiline title
par(oma=c(2, 0, 4, 0))
### Some greek letters
mu <- 0
alpha <- 1
beta <- 2
delta <- 3
lambda <- 4
### Some graph or other
plot(1:10,1:10)
mtext(expression(bold("Meaningless Title")),
line=3.5,cex=1.15)
mtext(bquote(paste(lambda==.(lambda),", ",
alpha==.(alpha),", ",
beta==.(beta),", ",
delta==.(delta),", ",
mu==.(mu),sep="")),
line=2.25,cex=1.15)
Best wishes
David Scott
>
>
>
> ----- Original Message ----
> From: David Scott <d.scott at auckland.ac.nz>
> To: Jason Rupert <jasonkrupert at yahoo.com>
> Cc: "R-help at r-project.org" <R-help at r-project.org>
> Sent: Wed, January 20, 2010 3:49:40 PM
> Subject: Re: [R] Greek letters on a multi-line plot title
>
> Jason Rupert wrote:
>> I have an instance where I need to include Greek letters on a plot title that is multiple lines. I've searched the forums for an approach to do this, but most of the previous posts and replies seem to just address instances of single line examples and problems:, e.g. https://stat.ethz.ch/pipermail/r-help/1999-October/005096.html
>> I tried implementing those suggestions, e.g. "expression(paste(...))", but that seemed to remove all the line split formating, i.e. "\n".
>> In the example code below I would like the sigma to be the lower case Greek symbol for sigma. Actually I would like the x and y to be subscripts of the lower case Greek symbol, but I suppose that is the next step. I guess the key is that I would like to maintain the multiple line title while having the Greek letters. Thanks again for any feedback. and insights.
> number_vals<-100
> x<-rnorm(number_vals)
> y<-rnorm(number_vals)
> plot(1, 1,
> xlim= c(min(x), max(x)),
> ylim= c(min(y), max(y)), col=0)
> points(x, y)
> the_expression<-paste("Plotting y vs. x",
> "\n sigma x = ", format(sd(x), digits=4, scientific=F),
> "\n sigma y = ", format(sd(y), digits=4, scientific=F), sep="")
> title(the_expression)
> grid()
>
> When confronted with this problem, after many failed attempts, I have had to resort to mtext.
>
> David Scott
>
>
> -- _________________________________________________________________
> David Scott Department of Statistics
> The University of Auckland, PB 92019
> Auckland 1142, NEW ZEALAND
> Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
> Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018
>
> Director of Consulting, Department of Statistics
>
>
>
>
--
_________________________________________________________________
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142, NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018
Director of Consulting, Department of Statistics
More information about the R-help
mailing list