Skip to contents

Overview

ggrepel provides geoms for ggplot2 to repel overlapping text labels:

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)

Installation

# The easiest way to get ggrepel is to install it from CRAN:
install.packages("ggrepel")

# Or get the latest development version from GitHub:
# install.packages("devtools")
devtools::install_github("slowkow/ggrepel")

Getting help

Check out the examples to learn how to use ggrepel in your project.

See our collection of related work for similar R packages, Python packages, and more.

If you have an issue with ggrepel or ggplot2, someone might already have experienced it. Try searching the web, or create a new post:

  1. The RStudio community is an active forum with RStudio and R users.

  2. Stack Overflow has lots of questions and answers about ggplot2 and ggrepel.

Examples

Click one of the images below to view the source code for that figure:

Hide some of the labels Always show all labels, even when they have too many overlaps Do not repel labels from data points Do not repel labels from plot (panel) edges Expand the scale to make room for labels Always (or never) draw line segments Make curved line segments or arrows Repel labels from data points with different
sizes Limit labels to a specific area Remove “a” from the legend Align labels on the top or bottom edge Align labels on the left or right edge Using ggrepel with stat_summary() Justify multiple lines of text with hjust Label jittered points Nudge labels in different directions with ggpp Label sf objects Shadows (or glow) under text labels Verbose timing information Word cloud Polar coordinates Unicode characters (Japanese) Mathematical expressions

Thanks

Thanks to everyone who has contributed pull requests, opened issues, asked questions, and shared examples!

And thanks to Allison Horst for the beautiful artwork!