Changing color of bars by treatment

29 views
Skip to first unread message

Shams Tabrez Khan

unread,
Sep 16, 2022, 1:50:45 AM9/16/22
to ggp...@googlegroups.com
Hello I am plotting the following data, want to use different color schemes for bars by treatment. Please help

>df<-data.frame(Mean=c(15,29,32,19,27,29,32,35,41,32,34,34,36,39),
Treatment=as.factor(c("C1","C2","ZN","ZN","ZN","ZN","ZN","ZN","ZB","ZB","ZB","ZB","ZB","ZB")),
Dose_ppm=c("0.0","0.0","5.0","10.0","15.0","20.0","25.0","50.0","5.0","10.0","15.0","20.0","25.0","50.0"),
Insert= c(0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5))
>df$Dose_ppm <- as.factor(df$Dose_ppm)
>df$Dose_ppm <- factor(df$Dose_ppm, levels = c("0.0","5.0","10.0","15.0","20.0","25.0","50.0"))
>library(ggplot2)
>ggplot(df, aes(x=Dose_ppm, y=Mean, fill=Treatment)) +
geom_bar(position=position_dodge(), alpha = 0.5, stat="identity",
colour='black') + labs(x="Zn Conc (ppm)", y="Zn Conc in plant tissues (mg/kg)")
Reply all
Reply to author
Forward
0 new messages