Adding colour to waterlogging treatments

Below is my r code, but I'm just wondering if I can get some help in making my geom_bar plot coloured. I need to have the waterlogging treatments (control, early, etc) different colours with a key. I can't seem to figure it out. Would be greatly appreciated.

NAME: All Species Mean Dry Shoot Biomass (g) at harvest


#Make sure it reads them as factors not as integers.$Waterlogging <- as.factor($Waterlogging)$Species <- as.factor($Species)$Tops.dry.g.mean <- as.factor($Tops.dry.g.mean)

ggplot(, aes(x=Waterlogging, y=Tops.dry.g.mean, group=Species)) +
geom_bar(stat = "identity", position=position_dodge()) +
geom_errorbar(aes(,, width=0.4, color = "black") +
coord_cartesian(ylim = c(0, 40)) +
labs(x = "Species", y = "Mean Dry Shoot Biomass (g)") +
theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black")) +
theme_classic(10) +
theme(axis.text.x = element_text(angle = 90)) +
theme(legend.position="bottom") +
scale_linetype_manual("dotted") +
facet_wrap(~Species, ncol = 5, strip.position = "bottom")


Try fill = Species instead.

Also, next time, please add a reproducible example (we don't have access to your dataset).

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.