How can I add the value of geom_vline to the graph? I am able to add the "Avg." label, but cannot add the actual value

I figured it out, so I'll share for other's reference. See the code changes I made below:

july_p <- ggplot(july_selected, aes(x=Score, y=sites, fill=PM))+ geom_bar(stat="identity")+ facet_wrap("PM")+theme_minimal()+theme(legend.position="top")+ scale_y_discrete(limits=rev)+
facet_wrap(~fct_relevel(PM,"37","40","44","50", "51", "52", "53", "55", "66", "67", "98", "100", "101", "102", "103"))+
theme(legend.position = "none")+
labs(
x="",
y="")+
ggtitle('Score by Performance Measure')

july_p <- july_p +
geom_vline(july_selected, mapping = aes(xintercept=as.numeric(Avg.)), color="black", alpha=.7, size=.7) +
geom_text(mapping = aes(x=Avg.-25), label='Avg.', color="#174873", y=1.2, size=4, )+
geom_text(mapping = aes(x=Avg.-5,y=1.2, label = Avg., inherit.aes = TRUE))

2 Likes