Re: [R] fancy text in pairs()

From: Charilaos Skiadas <cskiadas_at_gmail.com>
Date: Wed, 14 May 2008 22:04:57 -0400

On May 14, 2008, at 9:28 PM, Michael.Scroggie_at_dse.vic.gov.au wrote:

> Dear List,
>
> I'm currently trying to produce a number of pairs() plots with special
> text labels in the diagonal panels giving the units for the various
> quantities.
> These labels stretch across multiple lines, with the names of the
> quantities
> and the symbols for the units on separate lines. This seems to be
> leading
> to
> problems with the justification of the text that I can't seem to
> work out.
>
>
> The code below gives an example of what I have in mind with some
> fake data and units to illustrate. Has anyone got some ideas on how
> to modify my code so that I can have both the name of the quantity and
> the symbol for the unit nicely centred within the diagonal panel, one
> above the
> other?
>
> I'm running R 2.7.0 under windows XP.
>
>
> #generate some fake data:
> x1<-rnorm(100, 10, 1)
> x2<-rnorm(100, 5, 1)
> x3<-rnorm(100, 100, 2)
> X<-cbind(x1, x2, x3)
>
>
> #character vector of labels..
> labs<-c(
> expression(paste("Pressure \n", "(kg ", m^-2,")")),
> expression(paste("Acceleration \n", "(", "m ", s^-1, s^-1,")")),
> expression(paste("Concentration \n","(", mu, g," ", L^-1,")"))
> )
>
> #make a pairs() plot of the data.
> pairs(X, labels=labs, las=1, label.pos=0.5)
>

Try this:

labs <- expression(atop(Pressure,(kg * m^-2)), atop(Acceleration, (m*s^-1*s^-1)),atop(Concentration,(mu*g*L^-1))) pairs(X, labels=units, las=1, label.pos=0.5)

> Thanks for any solutions or suggestions,
>
> Michael Scroggie.
>

Haris Skiadas
Department of Mathematics and Computer Science Hanover College



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 15 May 2008 - 04:35:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 15 May 2008 - 06:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive