Questions tagged [ggrepel]

ggrepel: Repulsive Text and Label Geoms for 'ggplot2' Provides text and label geoms for 'ggplot2' that help to avoid overlapping text labels. Labels repel away from each other and away from the data points.

Repulsive Text and Label Geoms for

Description

Provides text and label geoms for 'ggplot2' that help to avoid overlapping text labels. Labels repel away from each other and away from the data points.

Repositories

154 questions
196
votes
3 answers

Label points in geom_point

The data I'm playing with comes from the internet source listed below nba <- read.csv("http://datasets.flowingdata.com/ppg2008.csv", sep=",") What I want to do, is create a 2D points graph comparing two metrics from this table, with each player…
Green Demon
  • 3,550
  • 6
  • 21
  • 31
13
votes
1 answer

Automatic Label Placement for GIS maps in R

I'm making GIS maps in R using the sf package (and related packages) to read in shapefiles, and ggplot2 (and friends) for plotting. This works fine, but I can find no way to (automatically/programmatically) create label placements for features such…
invertdna
  • 171
  • 6
12
votes
3 answers

ggrepel label with transparent background but visible font

Is there somehow a trick to get the font within 'geom_label_repel' alpha=1 but the background maybe alpha=.2? My problem is, that I have sometimes very dense plots. If I use just text, the text is not readable anymore. If I use label without…
drmariod
  • 9,470
  • 8
  • 48
  • 96
11
votes
1 answer

How do I include italic text in geom_text_repel or geom_text labels for ggplot?

Is it possible to pass partially italicized text labels into ggplot? I have tried using the expression and italic commands (expression(paste(italic("some text")))), but these cannot be passed into a data frame because the result of the commands is…
Bob
  • 371
  • 1
  • 4
  • 12
9
votes
2 answers

How do I shade plot subregion and use ggrepel to label a subset of data points?

I made this Volcano plot and am hoping to improve it as follows: fully shade the region with blue data points: with my current code, I wasn't able to extend the shade beyond what you see. I would like it to go all the way to the plot area limits. …
JernejT
  • 161
  • 7
9
votes
1 answer

R ggplot2 ggrepel - label a subset of points while being aware of all points

I have a rather dense scatterplot that I am constructing with R 'ggplot2' and I want to label a subset of points using 'ggrepel'. My problem is that I want to plot ALL points in the scatterplot, but only label a subset with ggrepel, and when I do…
Reilstein
  • 883
  • 1
  • 9
  • 23
9
votes
2 answers

Add labels to the center of a geom_curve line (ggplot)

Is there any way to add a label on or near the center of a geom_curve line? Currently, I can only do so by labeling either the start or end point of the curve. library(tidyverse) library(ggrepel) df <- data.frame(x1 = 1, y1 = 1, x2 = 2, y2 = 3,…
Watanake
  • 253
  • 2
  • 9
9
votes
1 answer

How to let geom_text inherit theme specifications? (ggplot2)

Is there an elegant way in ggplot2 to make geom_text/geom_label inherit theme specifications like a base_family? Or asked the other way round: Can I specify a theme that also applies to geom_text/geom_label? Example: I want text/labels to look…
gosz
  • 1,656
  • 2
  • 13
  • 26
8
votes
2 answers

ggrepel remove line around labels

How can I remove the line around geom_label_repel. Using label.size = 0 appears to have no visible effect. I could set `colour library(ggplot2) library(ggrepel) ggplot(mtcars, aes(wt, mpg, color = wt)) + geom_point(color = 'red') + …
Hugh
  • 13,468
  • 6
  • 48
  • 90
7
votes
2 answers

Changing the position of the label in a donut chart

I am trying to move the position of the label in a donut chart to be at the right side of the chart but I am not able to do it. I am using ggplot and ggrepel to make the graph. library(ggplot2) library(ggrepel) expenditurePie = data.frame( value…
Bruno Guarita
  • 653
  • 7
  • 18
7
votes
1 answer

Repel text from edges in network

When drawing a network, it would be nice if the labels of the nodes could also avoid network edges. E.g. in the example below, it would be possible to move all the labels outside the network. I've tried several packages, but so far have not found…
puslet88
  • 1,208
  • 13
  • 24
7
votes
1 answer

Is it possible to avoid axis label overlapping by ggrepel?

I am drawing heatmap with ggplot2. Several ticks on y axis need to be labeled. However,some of them are too close and overlap. I know ggrepel could separate text labels, but currently I have not worked out for my problem. My code is as following.…
PengY
  • 73
  • 4
7
votes
3 answers

Aligning labels with ggrepel

According to the most recent updates, ggrepel now supports hjust and vjust. According to the documentation, using this should align all of the labels. However, I'm unable to get the labels to align, as seen below I have…
Adam_G
  • 6,417
  • 17
  • 69
  • 120
6
votes
1 answer

Add an arrow with filled head to ggplot by geom_label_repel

I want to add an arrow with a filled head to a ggplot object by using the geom_label_repel function. I thought that I could use: arrow.fill = 'black' like I do with the geom_segment, but it does not work in the geom_label_repel. Is it another way to…
gentiana
  • 107
  • 7
6
votes
1 answer

How to combine repelling labels and shadow or halo text in ggplot2?

There are some nice solutions for either repelling labels in ggplot2 (e.g. ggrepel) or shadow text for labels (e.g. ggshadowtext and this answer). But nothing that allows us to combine these two functions. I tried this hack that prints the labels…
Ben
  • 38,669
  • 17
  • 120
  • 206
1
2 3
10 11