Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
491 views
in Technique[技术] by (71.8m points)

r - Is there a way to make sure that the labels on my graph dont overlap with each other other than ggrepel as that seems to run forever

I'm trying to make sure that the district labels don't overlap on my graph as they are kinda congested and too many. However, using geom_text_repel produces no results even when I let it run for hours. Please help me out I have been stuck on this for so long. I have attached the picture for when I use the simple geom_text( without the repel)

    w <-  map_and_data%>%
  group_by(districts)%>%
  mutate(avgterror=mean(Typetattacksmilitants)*100)

options(ggrepel.max.overlaps = Inf)

n <- ggplot(w,aes(total,avgterror,label=districts)) + geom_point() +
  labs( title = "Relationship between Average Number of Terrorist attacks and Frequency of Cellphone Shutdowns",
        caption="Grouped by District",
        x="Frequency of Cellphone Shutdowns",
        y="Average number of Terrorist Attacks") +
 geom_text_repel(aes(label=districts)) 

This is my plot with overlaps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...