Adding colour to waterlogging treatments

Hi,
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

view(plotting.harvest.data)

#Make sure it reads them as factors not as integers.

plotting.data.harvest$Waterlogging <- as.factor(plotting.data.harvest$Waterlogging)
plotting.data.harvest$Species <- as.factor(plotting.data.harvest$Species)
plotting.data.harvest$Tops.dry.g.mean <- as.factor(plotting.data.harvest$Tops.dry.g.mean)

ggplot(data=plotting.harvest.data, aes(x=Waterlogging, y=Tops.dry.g.mean, group=Species)) +
geom_bar(stat = "identity", position=position_dodge()) +
geom_errorbar(aes(ymin=Tops.dry.g.mean-Tops.dry.g.se,
ymax=Tops.dry.g.mean+Tops.dry.g.se), 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")

Hello,

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.