How to algin the label with corresponding point correct?

By the effect of "jitter", it seems can't control the relative position between of pair of label of geom_text and point of geom_point.

In the graph, I connect the pair which i can identify by black line. But, in fact, I almost can't make sure what are the correct pair due to the distance and related-position between label and point are dynamic.

Are there any master can offer some view to solve that problem?

Thanks so much!!

p4<-mpg.df %>%
  ggplot(aes(displ,hwy,color=cn))+
  geom_jitter(shape=21,size=5,position=position_jitter(width=0.5,height=5))+
  #geom_jitter(shape=21,colour=ifelse(as.numeric((rownames(mpg.df)))%%2==0,"red","green"),size=2,stroke=0.1,width=1,height=10)+
#geom_text(aes(label=rownames(mpg.df)))
  geom_text(aes(label=cn),size=2,position=position_jitter(width=0.5,height=5))+
  guides(color=FALSE)

[i use black line to show the corresponding label and point, but almost can't identify all rest pair]

1



Read more here: https://stackoverflow.com/questions/68092364/how-to-algin-the-label-with-corresponding-point-correct

Content Attribution

This content was originally published by Giant Hara at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: