[R] ggplot2: geom_segment does not produce the color I desire?

John miaojpm at gmail.com
Sat Sep 17 00:43:03 CEST 2016


Hi,

   I have a dataset "test". I try to produce a "green" arrow but it gives a
"red" arrow (as attached). Could someone tell me how I can fix it? Thanks,

> 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())
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_plot1609.pdf
Type: application/pdf
Size: 4609 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160916/1ac3dd1e/attachment.pdf>


More information about the R-help mailing list