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

206 questions
3
votes
0 answers

ggplot2 labels hidden behind bar plot

So I have this code: ggplot(aes(x=Year,y=Household.Expenditure.Total, fill=Household.Expenditure.on.Tobacco, label=Expenditure.on.Tobacco.as.a.Percentage.of.Expenditure))+ theme_classic()+ geom_text_repel()+ …
Anastasia
  • 51
  • 1
  • 3
3
votes
1 answer

ggplot color legend shape mixes alphanumeric and shape

The inclusion of ggrepel in a ggplot leads to a funny shape in the legend: . Q: How do I replace this with a normal shape? Sample code: data(mtcars) library(ggplot2) library(ggrepel) ggplot(mtcars, aes(x = mpg, y = wt, color = factor(vs), size =…
Henk
  • 3,634
  • 5
  • 28
  • 54
2
votes
0 answers

Label a map with lead lines/call out using tmap in R

I am trying to produce a map using the tmap library. I want to label all areas and use lead lines to label tiny areas. I'm looking for a line of code that works like ggrepel in ggplot2 or geom_sf_label_repel in the sf library but for tmap. Here is a…
Joke O.
  • 515
  • 6
  • 29
2
votes
2 answers

geom_smooth with geom_label_repel creates unwanted multiple labels

I start off without including the data. The problem comes from using geom_smooth with lots of data points (i.e. a large data set), so a minimal data example for illustration purposes seems difficult to use (I tried). But I can submit the data if…
cibr
  • 453
  • 5
  • 16
2
votes
1 answer

How to use ggrepel with a survival plot (ggsurvplot)?

I would like to add the label of each survival curve at the end of the lines. I am using ggsurvplot from the Survminer package (which is based on ggplot2). I don't know how to do it with ggrepel. I didn't find any example with survival…
Flora Grappelli
  • 659
  • 9
  • 26
2
votes
1 answer

How to horizontally align repelled labels for overlapping points

Data: df <- structure(list(interval = c("1990-1994", "1995-1999", "2000-2004", "2005-2009", "2010-2014"), G = c(82.2047540759008, 66.8830947511929, 60.8452885555918, 60.815015015015, 56.9713761985336), I = c(0.0816584033395321,…
syre
  • 902
  • 1
  • 7
  • 19
2
votes
1 answer

label end of lines outside of plot area

I am trying to replicate this figure from the Financial Times. Here is a gist with the data. I'm struggling to label the end of the lines because I run out of room in the plot. I found a few ways to expand the limits of the plot area, but this is…
Eric Green
  • 7,385
  • 11
  • 56
  • 102
2
votes
1 answer

How to nudge starting point of segments in geom_text_repel when axis is discrete?

library(tidyverse) library(ggrepel) df <- iris %>% pivot_longer(starts_with("Sepal")) %>% group_by(Species, name) %>% summarise( y0 = min(value), y1 = max(value) ) I'm often using the ggrepel package for adding labels and…
Peter H.
  • 1,995
  • 8
  • 26
2
votes
1 answer

ggplot2 and sf: geom_sf_text within limits set by coord_sf

I am using sf and ggplot2 to read shapefiles as simple features and plot various maps. I have been working through the maps chapter in the ggplot2 book but could not really find an answer to the following issue: Plotting a map using geom_sf and…
dirk
  • 45
  • 1
  • 7
2
votes
0 answers

R plotly - overlapping points and labels

I have an R shiny application and on one page I have a scatter plot with about 100 markers. My goal is to add a label to each marker as explained here https://plotly.com/r/text-and-annotations/ It kind of words but the problem is that the text of…
Angelo
  • 1,594
  • 5
  • 17
  • 50
2
votes
0 answers

Using geom_dl to label multiple geom_smooth plots

I have a dataset of all football (soccer) transfers made in the last fifteen seasons. I am doing a regression analysis with the placement of the teams. I am plotting the lines via geom_smooth for all of the five respective leagues. I have chosen to…
Antlserum
  • 21
  • 1
2
votes
1 answer

centering the label segment starting points for labelled pie charts

I am trying to create a labelled pie chart using ggrepel based on a StackOverflow answer, but I can't seem to get the position of the labels correctly. Ideally, I would like the segments that connect the labels to the portion of the pies to start in…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
0 answers

Geom label repel when label is too long to fit in the plot

Does anyone know how to ensure that all the labels fit into the frame or expand the it beyond the chart without having the labels cut off? Would also love to know how i can adjust the position of the label boxes and if there's any way to wrap text…
Kent
  • 21
  • 2
2
votes
0 answers

ggrepel: plot labels outside map

I'm doing a map of China biggest cities in terms of population using ggplot2. The initial dataset was in a shapefile therefore I used readOGR to convert the data into a Spatial vector object and then using fortify I turned the map into a dataframe…
lber
  • 23
  • 5
2
votes
2 answers

Labeling a single point with ggrepel

I am trying to use geom_label_repel to add labels to a couple of data points on a plot. In this case, they happen to be outliers on box plots. I've got most of the code working, I can label the outlier, but for some reason I am getting multiple…
Alex
  • 261
  • 2
  • 5
  • 11