Skip to content
/ repel Public
forked from slowkow/ggrepel

📍 Repel overlapping text labels away from each other.

License

Notifications You must be signed in to change notification settings

hms-dbmi/repel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

repel helps repel overlapping text labels. It is forked from ggrepel to help in a non ggplot2 context. Work in progress.

Installation

# install.packages("remotes")
remotes::install_github("hms-dbmi/repel")

Usage

library(repel)

# plot points
plot(mpg ~ wt, data = mtcars, pch = 19, cex=0.4, col = 'red')

# construct label_coords
label_coords <- mtcars[, c('wt', 'mpg')]
colnames(label_coords) <- c('x', 'y')
label_coords$label <- row.names(mtcars)

# get coords of repelled labels and exclude if too much overlap
repels <- repel_text(label_coords)
repels <- repels[!repels$too_many_overlaps, ]

# plot labels and segments
text(label_coords$x, label_coords$y, labels = label_coords$label, col='lightgray')
text(repels$x, repels$y, labels = repels$label)

mtcars

About

📍 Repel overlapping text labels away from each other.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 73.4%
  • R 26.6%