R: How can I annotate a ggplot with a text box?

前端 未结 1 1346
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 15:40

I am looking to add a small white text box, with custom text in the body of my ggplot plot. The text I want to add is to identify a horizontal line I am adding to the plot.

1条回答
  •  一生所求
    2021-02-07 16:06

    You can simply change to

    annotate("label", x = max(grossunits), y = meancbrate, label = "avg rate") 
    

    which will use geom_label rather than geom_text and so you get a rectangle around the label.

    0 讨论(0)
提交回复
热议问题