Skip to content
Prev 181607 / 398502 Next

Labeling barplot bars by multiple factors

You can get something close with ggplot2:

library(ggplot2)
my_data = expand.grid(
	A = factor(c('A1','A2'))
	, B = factor(c('B1','B2'))
	, C = factor(c('C1','C2'))
)
my_data$DV = rnorm(8,mean=10,sd=1)
p = ggplot()
p = p + layer(
	geom = 'bar'
	, stat = 'identity'
	, data = my_data
	, mapping = aes(
		x = C
		, y = DV
		, fill = B
	)
	, position = 'dodge'
)
p = p + facet_grid(
	A ~ .
)
p = p + coord_flip()
print(p)
On Wed, May 27, 2009 at 1:01 PM, Thomas Levine <thomas.levine at gmail.com> wrote: