This is my data:
Guild Treatment value
Ins Low 59.1
InsAerGleEdge Low 19.7
InsAerOpen Low 6.7
InsAerGleEdgeClut Low 4.4
Frug Low 3.7
InsAerGleClut Low 3.5
InsAerEdge Low 2.3
InsGleClut Low 0.6
InsAerOpen Medium 40.1
Frug Medium 24.3
Ins Medium 24.3
InsAerGleEdge Medium 5.3
InsAerEdge Medium 2.6
InsAerGleEdgeClut Medium 2.6
InsGleClut Medium 0.7
InsAerGleClut Medium 0
Frug High 27.8
InsAerEdge High 18.6
InsAerGleClut High 16.7
InsAerGleEdge High 15.5
Ins High 11.7
InsAerOpen High 5.8
InsAerGleEdgeClut High 3.7
InsGleClut High 0.3
I would like to have a barplot using ggplot keeping the sequence of the guilds for each treatment. For example in:
- Treatment
Low
the sequence of guilds isIns, InsAerGleEdge, InsAerOpen
etc..based on the highest value. - Treatment "Medium" is
InsAerOpen, Frug, Ins
etc.
My problem is when I plot it in all the treatments it starts with the same guild.
I have tried "reorder", "factor" but it doesn't change for each treatment individually.
Treatment<-as.character(df$Treatment)
df$Treatment<-factor(df$Treatment, levels = c("Low", "Medium","High"))
m<-ggplot(df, aes(fill=Guild, y=value, x=Treatment)) +
geom_bar(position=position_dodge(), stat="identity",color="grey60")+
scale_fill_manual(values=c("grey80", "grey30","grey60","grey40","grey50","grey70","grey90","grey20"))