I'm trying to add a caption to geom_hline ()
but I don't know how I can do it.
I would like the name "historical serie" and the value "'18" to appear in front of the line, as in the example in the image.
I tried geom_hline (aes (yintercept = 18, 'Historical serie'), size = 1.5, col =" # ffff00 ")
but it returns an error. I took 'Historical serie' it worked, but the caption does not appear.
my code
> date2<-c('01/01/2000','08/08/2000','16/03/2001','06/09/2001')
> name<-c('A','B','A','B')
> total<-c(23,25,36,41)
> esp<-c(0.363,0.4123,0.09,0.65)
>
> ggplot(data=df, aes(x=year_date, y=total, fill=name))+
> geom_col(position = "dodge")+
> scale_fill_manual(values=c("#08088A","#9F81F7"))+
> theme_light()+labs(fill="rain", title ="rain anual", x="Estation", y="total mm")+
> theme(axis.text.x = element_text(angle = 90))