Tool: ggrepel: repel overlapping text labels in ggplot2
15
gravatar for Kamil
3.2 years ago by
Kamil1.9k
Boston
Kamil1.9k wrote:

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)

animation of ggrepel

visualization tools R • 4.6k views
ADD COMMENTlink modified 4 months ago by RamRS20k • written 3.2 years ago by Kamil1.9k
1

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.

ADD REPLYlink modified 3.2 years ago • written 3.2 years ago by Daniel3.7k

Thanks for catching this! I missed it.

ADD REPLYlink written 3.2 years ago by Kamil1.9k

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

ADD REPLYlink written 3.2 years ago by Daniel3.7k

Well done! This great!

ADD REPLYlink modified 4 months ago by RamRS20k • written 3.2 years ago by Devon Ryan88k

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 

ADD REPLYlink written 3.2 years ago by svlachavas560
1

Efstathios, thanks for your question!

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.

ADD REPLYlink modified 4 months ago by RamRS20k • written 3.2 years ago by Kamil1.9k

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

ADD REPLYlink written 3.2 years ago by svlachavas560

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

ADD REPLYlink modified 4 months ago by RamRS20k • written 3.1 years ago by Sukhdeep Singh9.6k

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.

Thanks in advance, Grant

ADD REPLYlink written 2.9 years ago by grant.hovhannisyan1.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1811 users visited in the last hour