我想根据方向改变箭头的颜色。我想在情节中插入箭头,但目前它们都是黑色的。我想要从左到右的绿色箭头和从右到左的红色箭头。那可能吗?
这是我的“短”代码:
library(ggplot2)
name = c("Name1","Name2", "Name1", "Name2")
time = c("1", "3","4","2")
value = c(5.1, 4.8, 4.1, 6.3)
data <- data.frame(name, time, value)
p <- ggplot(data, aes(x=value, y=name)) +
geom_point(aes(colour=time), shape=16, size=6) +
geom_path(aes(group=name), arrow=arrow(length=unit(0.15,"cm")), colour="black", size=1)
print(p)
提前感谢您提供的任何帮助!