示例代码
library(ggplot2)
ggplot(mtcars, aes(mpg, cyl, color = vs)) + geom_line()
如何像在使用上图所示的示例中那样向x轴添加任意文本,然后在上面写上“任意单词”
答案 0 :(得分:3)
我不确定您要做什么,这可能会也可能不会很好地概括。
也就是说,一种可能性是将annotate
与coord_cartesian(clip = "off")
一起使用以允许绘图区域之外的文本。
ggplot(mtcars, aes(mpg, cyl, color = vs)) +
geom_line() +
annotate("text", x = 12.5, y = 3.5, label = "Arbitrary text") +
coord_cartesian(ylim = c(4, 8), clip = "off")
答案 1 :(得分:1)