I am generating ggplot2 stacked bar plots. Everything is fine, here is my code
> ab<-read.table("ab.txt", header=TRUE, sep="\t")
> head(ab)
id P1 P2 P3
1 A 1 6 5
2 B 6 5 3
3 C 8 5 3
4 D 7 1 2
5 E 8 2 1
> library("reshape2")
> ab1<-melt(ab)
Using id as id variables
> head(ab1)
id variable value
1 A P1 1
2 B P1 6
3 C P1 8
4 D P1 7
5 E P1 8
6 A P2 6
> library("ggplot2")
> ab1$id <- factor(ab1$id, levels=ab1$id)
> p<-ggplot(data=ab1, aes(x=id, y=value, fill=variable))+geom_bar(stat="identity", width=1)+scale_y_continuous(expand = c(0,0)) <br/>
> p
But I like to have same x-axis labels for more than one bar, like common label for first three bars.
Something like this:
Here, a common label 'Coconut' for first three bars and second 'Rice' for next three bars. If possible for first and next three bars to distinguish.
I am not interested in doing this using facet_grid.
Thanks in advance
Ramesh