text label in geom_jitter, ggplot2 in r

how can I add short line from to text to its corresponding point here?


  ggplot(DEGs, aes(x = pair, y = avg_log2FC, color=change)) + 
   geom_jitter(width = 0.4, height = 0, size = 1) +
    scale_color_manual(values = c('up' = '#D53E4F','stable' = 'gray','down' = '#3288BD')) + 
      mapping = aes(label= label), color = "black", 
      size = 3) +
    theme(panel.grid.major =element_blank(), panel.grid.minor=element_blank(),     
          axis.title.x = element_blank()) +
    guides(color = guide_legend(override.aes = list(size = 3)))  

geom_text_repel() adds lines automatically, if it has to move the text too far away from the point. However, in your case I believe points and texts are not aligned correctly. You are using geom_jitter(), witch scatters points randomly in the x-axis. I don't know how large your pair values are, but I have a feeling that the plot is dominated by random jitter. This is why Lars21 is far away from the point. geom_text_repel() uses the exact x value (as specified by pair column), while geom_jitter() moved this point by random value. I'm not sure what your are trying to achieve here, but I'd suggest using geom_point() instead of geom_jitter().