gpt4 book ai didi

r - 在 R 图中显示值

转载 作者:行者123 更新时间:2023-12-03 23:02:04 26 4
gpt4 key购买 nike

如何在 plot 中呈现点的值在 plot本身?

谢谢你。

最佳答案

b0 = 2.5; b1 = 2
n = 100
x = rnorm(n, 20, 15)
y = b0 + b1*x + rnorm(n, 0, 15)
plot(x, y)
plot(x, y, type='n')
text(x, y, round(y, 2), cex=0.45)
text(x, y, round(y, 2), cex=0.8)
text(x, y, paste(round(x, 2), round(y, 2), sep=", "), cex=0.8) # for (x, y), but this gets cluttered.

alt text

使用 cex字符大小(请参阅文本帮助)。并使用 plot(x, y, type='n')在不实际绘制任何内容的情况下正确设置窗口。

关于r - 在 R 图中显示值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1449266/

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