gpt4 book ai didi

r - 在 R 图的图例中绘制 "arrow"

转载 作者:行者123 更新时间:2023-12-03 21:26:58 28 4
gpt4 key购买 nike

我有一个 “曲线”和直立定位 “箭头”在 R 图中( 参见下面的 R 代码 )。

我想知道是否可以显示 实际箭头 《传奇》 而不是 光滑,直线来区分我的箭头和曲线?

这是我的 R 代码:

curve(dnorm(x), -4, 4, lwd = 3)

arrows(2, 0, 2, .3, code = 2, lwd = 3, col = 'red4')

legend("topleft", legend = c("Curve", "Arrow"), lwd = 3, col = c(1, "red4"))

最佳答案

以下是如何在您的图例中放置一个右箭头代替线。您必须使用 par 访问 font = 5得到一个箭头符号。

curve(dnorm(x), -4, 4, lwd = 3)
arrows(2, 0, 2, .3, code = 2, lwd = 3, col = 'red4')
legend("topleft", legend = c("Curve", "Arrow"), pch = c(NA, NA),
lwd = 3, col = c(1, "red4"),
lty = c(1, NA)) #normal legend. Do not plot line
par(font = 5) #change font to get arrows
legend("topleft", legend = c(NA, NA), pch = c(NA, 174),
lwd = 3, col = c(1, "red4"),
lty = c(1, NA), bty = "n")
par(font = 1) #back to default

enter image description here

关于r - 在 R 图的图例中绘制 "arrow",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43052670/

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