R ggplot2: Labelling a horizontal line on the y axis with a numeric value

前端 未结 4 1539
春和景丽
春和景丽 2020-12-05 02:12

I have a horizontal line in a ggplot and I would like to label it\'s value (7.1) on the y axis.

library(ggplot2)
df <- data.frame(y=c(1:10),x=c(1:10))
h &         


        
4条回答
  •  猫巷女王i
    2020-12-05 03:07

    How about something like this?

    plot1 + geom_hline(aes(yintercept=h), colour="#BB0000", linetype="dashed") + 
     geom_text(aes( 0, h, label = h, vjust = -1), size = 3)
    

提交回复
热议问题