[R] Dual Category X-Axis (Multi-Level)

Greg Snow Greg.Snow at imail.org
Thu Feb 11 20:01:06 CET 2010


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
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----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)
> 
> Hello,
> 
> 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:
> http://peltiertech.com/WordPress/chart-with-a-dual-category-axis/).
> 
> 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,
> -eric
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list