示例代码
library(ggplot2)
ggplot(mtcars, aes(mpg, cyl, color = vs)) + geom_line()
如果可以像使用上面的图制作的这个示例中那样将任意文本添加到 x 轴,然后我在上面写上“任意文字”
最佳答案
我不完全确定你想要做什么,所以这可能会也可能不会很好地概括。
也就是说,一种可能性是使用 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")
关于r - 在绘图区域外添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54776142/