[R] Dual Category X-Axis (Multi-Level)
EPowell1 at med.miami.edu
Thu Feb 11 21:30:41 CET 2010
That's brilliant, Greg. Thanks a bunch!
From: Greg Snow [mailto:Greg.Snow at imail.org]
Sent: Thursday, February 11, 2010 2:01 PM
To: Powell, Eric; 'r-help at r-project.org'
Subject: RE: [R] Dual Category X-Axis (Multi-Level)
Using mtext is probably one of the most straight forward ways. You can also use something like:
par(mfrow=c(1,3), mar=c(5.1,0,4.1,0), oma=c(0,4.1,0,1.1))
one <- 1:3
two <- 2:5
three <- 6:4
names(one) <- LETTERS[1:3]
names(two) <- letters[2:5]
names(three) <- state.abb[6:4]
tmp.ylim <- range(0,one,two,three)
barplot(one, col='red', bty='n', xlab='one', ylim=tmp.ylim)
barplot(two, col='green', bty='n', xlab='two', ylim=tmp.ylim, ylab='', yaxt='n')
barplot(three, col='blue', xlab='three', bty='n', ylim=tmp.ylim, ylab='', yaxt='n')
Or you could put that in a loop.
Hope this helps,
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at imail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Powell, Eric
> Sent: Thursday, February 11, 2010 9:16 AM
> To: 'r-help at r-project.org'
> Subject: [R] Dual Category X-Axis (Multi-Level)
> I was wondering if anyone knows of a way to produce multilevel x-axis
> groupings similar to Excel's pivotcharts. (If you're not sure what I'm
> talking about, here's an example:
> I realize that I could use mtext to manually insert text where desired,
> but I was hoping for a more systematic approach.
> Thanks in advance,
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help