I want to add letters next to the bars as shown in the excel bar graph.
I have used this code and got this result
horiz <- 9.38
quux <- data %>%
select(Genotype,Specie, Pn, pn1) %>%
arrange(desc(Pn)) %>%
mutate(Genotype = factor(Genotype, levels = Genotype))
ggplot(quux, aes(Genotype, fill=Specie)) +
geom_rect(aes(xmin=as.numeric(Genotype)-0.4, xmax=as.numeric(Genotype) + 0.4,
ymin=pmax(horiz, Pn), ymax=pmin(horiz, Pn)))+
scale_x_discrete() + scale_y_continuous(breaks = seq(6.95, 12.41, 0.9))+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5))+
geom_hline(yintercept = 9.38, linetype = "dashed", color = "black")+
geom_text(aes(label = Genotype, y = horiz), angle=90, hjust = 1.1) +
theme(axis.text.x = element_blank(), axis.ticks.x = element_blank()) +
geom_text(data = data, aes(y = Pn+0.2, label = pn1),position = position_dodge(width = .75))