Add text outside plot area

前端 未结 2 989
慢半拍i
慢半拍i 2020-12-21 00:04

Sample code

library(ggplot2)
ggplot(mtcars, aes(mpg, cyl, color = vs)) + geom_line()

How if it is possible to add arbitrary text to the x a

2条回答
  •  醉梦人生
    2020-12-21 00:52

    You can use tag in ggplot2 (see ?ggplot2::labs) and specify it's position in theme

    library(ggplot2)
    ggplot(mtcars, aes(mpg, cyl, color = vs)) + 
        geom_line() +
        labs(tag = "arbitrary words") +
        theme(plot.tag.position = c(0.15, 0.02))
    

提交回复
热议问题