Tool:ggrepel: repel overlapping text labels in ggplot2
0
15
Entering edit mode
7.2 years ago
Kamil ★ 2.1k

ggrepel is an R package that provides geoms to repel overlapping text labels away from each other in a plot created by ggplot2.

## Installation

Install the stable release from CRAN:

install.packages('ggrepel')


Or, install the latest development version from github:

install.packages('devtools')
devtools::install_github('slowkow/ggrepel')


## Examples

See the vignette for more usage examples:

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


Tools R visualization • 15k views
1
Entering edit mode

You might want to indicate that it's dependant on ggplot2 version 2.0+, as it took a while for me to figure out why it was silently failing to install.

0
Entering edit mode

Thanks for catching this! I missed it.

0
Entering edit mode

Thank you, Thank you. A million times thank you.

0
Entering edit mode

Well done! This great!

0
Entering edit mode

Dear Kamil,

great implementation regarding the text labels, especially for volcano plots with a lot of gene symbols !! I have only one small question: if still with the similar code above, I have still some text labels not clearly shown, by which arguments can I control or improve the distance between these possible overlapping layers ?

Best,
Efstathios

1
Entering edit mode

Please see if the examples in the vignette might help to learn about the arguments. Try 'box.padding'.

If you need further help, could I ask you to continue this discussion in a new issue on the github repo? If you do not use github, feel free to create a new post on this page, under "Add your answer". Consider sharing a code example and an image of the plot to clarify the problem.

0
Entering edit mode

Dear Kamil,

i will check first the additional capabilities and your suggestions-if i continue having issues, i will post the code and a supportive image !!

Thanks,

Efstathios

0
Entering edit mode

Thanks for the ggrepel Kamil. I also suggested this to someone last month

0
Entering edit mode

Dear Kamil, Thanks a lot for the ggrepel!

One question: is it possible to remove linking lines between datapoints and labels that are close to each other, e.g. for Chrysler Imperial (bottom right corner) or Toyota Corolla (top left corner) on your example. This will make the plot even nicer.