gpt4 book ai didi

r - 在绘图区域外添加文本

转载 作者:行者123 更新时间:2023-12-03 15:07:55 26 4
gpt4 key购买 nike

示例代码

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

如果可以像使用上面的图制作的这个示例中那样将任意文本添加到 x 轴,然后我在上面写上“任意文字”

enter image description here

最佳答案

我不完全确定你想要做什么,所以这可能会也可能不会很好地概括。

也就是说,一种可能性是使用 annotatecoord_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")

enter image description here

关于r - 在绘图区域外添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54776142/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com