I have a "curve" and an upright positioned "arrow" in an R plot (see R code Below).
I was wondering if it might be possible to show an actual arrow in the "legend" rather than a smooth, straight line to distinguish my arrow from the curve?
Here is my R code:
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"))
Here's how to put a right arrow in your legend in place of the line. You have to access font = 5 with par
to get an arrow symbol.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With