Here are 2 solutions to you problem: If you only want to use one color (for possibly many arrows), this will work:
ggplot()+geom_segment(mapping = aes(x = as.Date(test[,"date"]), y =y1, xend = as.Date(test[,"date"]), yend = y2), color="green", data=testdf, arrow=arrow()) if you use a variable to colors different items differently, you are using a mapping. If you want to override ggplot’s default mapping, you set the palette explicitly: ggplot()+geom_segment(mapping = aes(x = as.Date(test[,"date"]), y =y1, xend = as.Date(test[,"date"]), yend = y2, color=co), data=testdf, arrow=arrow()) + scale_color_manual(values=list(green="green")) > On Sep 17, 2016, at 00:43, John <miao...@gmail.com> wrote: > >> >> test > date co y1 y2 > 5 2011-11-28 green 196.6559 1.600267 >> dput(test) > structure(list(date = structure(15306, class = "Date"), co = "green", > y1 = 196.655872, y2 = 1.600267), .Names = c("date", "co", > "y1", "y2"), class = "data.frame", row.names = 5L) >> ggplot()+ geom_segment(mapping = aes(x = as.Date(test[,"date"]), y = > y1, xend = as.Date(test[,"date"]), yend = y2, color=co), data=test, > arrow=arrow()) >
signature.asc
Description: Message signed with OpenPGP using GPGMail
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.