Vertical lines between points with ggplot2

后端 未结 3 1010
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-06 02:45

I am new to ggplot2 and cannot figure out how to draw vertical dotted grey lines between

the points/dots along the x-axis. Here\'s my example code:

3条回答
  •  清歌不尽
    2021-01-06 03:29

    If your actual data is structured like the one used for your example, just add geom_line(aes(group = d3)) to the plot.

    ggplot(df, aes(x=x, y=y)) +  
     geom_point() + geom_line(aes(group = d3))
    

    enter image description here

提交回复
热议问题