我有一个 “曲线”和直立定位 “箭头”在 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
关于r - 在 R 图的图例中绘制 "arrow",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43052670/