ggplot2 line plot order

后端 未结 1 627
面向向阳花
面向向阳花 2020-12-10 12:09

I have a series of ordered points as shown below: \"enter

However when I try to connec

相关标签:
1条回答
  • 2020-12-10 12:18

    geom_path() will join points in the original order, so you can order your data in the way you want it joined, and then just do + geom_path(). Here's some dummy data:

    dat <- data.frame(x = sample(1:10), y = sample(1:10), order = sample(1:10))
    ggplot(dat[order(dat$order),], aes(x, y)) + geom_point() + geom_text(aes(y = y + 0.25,label = order)) +
      geom_path()
    

    enter image description here

    0 讨论(0)
提交回复
热议问题