我不确定您要做什么,这可能会或可能不会很好地概括。
也就是说,一种可能性是使用带有coord_cartesian(clip = "off")
annotate
来允许文字超出绘图区域。
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")