ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'
Art by Allison Horst

ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'

·106 words·1 min

ggrepel logo

ggrepel is an R package that provides geoms for ggplot2 to repel overlapping text labels:

  • geom_text_repel()
  • geom_label_repel()

Text labels repel away from each other, away from data points, and away from edges of the plotting area.

library(ggrepel)
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
 geom_text_repel() +
 geom_point(color = 'red') +
 theme_classic(base_size = 16)

ggrepel example

Check it out on GitHub 👇

CRAN_Status_Badge CRAN_Downloads_Badge

Here’s an animation that shows how the repulsion and attraction algorithm works:

Thanks to all of the wonderful people who have contributed issues and pull requests over the years! 🙏

Reply by Email