【问题标题】:geom_segment combined with geom_pointgeom_segment 与 geom_point 结合
【发布时间】:2014-09-15 17:32:34
【问题描述】:

我正在 ggplot 中绘制一个 geom_point,我想将它与从 x 轴到该点的段相结合。如何指定分段应 x 轴?

 head(pValues_Both.m)

  value
1 5.502
2 0.823
3 0.374
4 3.886
5 0.724
6 0.706

ggplot(pValues_Both.m, aes(x=seq_along(value),y=value)) +   geom_segment(aes(yend=value), xend=0, colour="grey50") +
  geom_point(size=3.5,colour="#2E64FE")

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    您也应该使用seq_along(value) 作为aes() 中的xend=geom_segment()

    ggplot(pValues_Both.m, aes(x=seq_along(value),y=value)) +   
          geom_point(size=3.5,colour="#2E64FE")+
          geom_segment(aes(yend=0,xend=seq_along(value)), colour="grey50")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-07
      • 2017-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多