See also
GeomLabel from the ggplot2 package.
GeomText from the ggplot2 package.
-
Useful links:
@@ -106,6 +107,7 @@ Author <
Michał Krassowski (ORCID ) [contributor]
Michael Chirico (ORCID ) [contributor]
Pedro Aphalo (ORCID ) [contributor]
+Francis Barton [contributor]
On this page
diff --git a/docs/reference/position_nudge_repel-1.png b/docs/reference/position_nudge_repel-1.png
index 69f9c7d..1e2241a 100644
Binary files a/docs/reference/position_nudge_repel-1.png and b/docs/reference/position_nudge_repel-1.png differ
diff --git a/docs/reference/position_nudge_repel-2.png b/docs/reference/position_nudge_repel-2.png
index 813b80a..3d11042 100644
Binary files a/docs/reference/position_nudge_repel-2.png and b/docs/reference/position_nudge_repel-2.png differ
diff --git a/docs/reference/position_nudge_repel-3.png b/docs/reference/position_nudge_repel-3.png
index d498808..0c91de0 100644
Binary files a/docs/reference/position_nudge_repel-3.png and b/docs/reference/position_nudge_repel-3.png differ
diff --git a/docs/reference/position_nudge_repel-4.png b/docs/reference/position_nudge_repel-4.png
index 6723027..1c916d0 100644
Binary files a/docs/reference/position_nudge_repel-4.png and b/docs/reference/position_nudge_repel-4.png differ
diff --git a/docs/reference/position_nudge_repel-5.png b/docs/reference/position_nudge_repel-5.png
index bbf518b..3b436a9 100644
Binary files a/docs/reference/position_nudge_repel-5.png and b/docs/reference/position_nudge_repel-5.png differ
diff --git a/docs/search.json b/docs/search.json
index 2195cf8..2899bad 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -1 +1 @@
-[{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"summary","dir":"","previous_headings":"","what":"Summary","title":"NA","text":"sentence briefly summarizes issue.","code":""},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"minimal-code-example","dir":"","previous_headings":"","what":"Minimal code example","title":"NA","text":"minimum amount code needed demonstrate issue: image output produced code: IMAGE","code":"ggplot(...) + geom_text_repel(...)"},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"suggestions","dir":"","previous_headings":"","what":"Suggestions","title":"NA","text":"proposal solve issue.","code":""},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"version-information","dir":"","previous_headings":"","what":"Version information","title":"NA","text":"output sessionInfo() R session:","code":"Paste output here"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Examples","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area (panel). Let’s compare geom_text() geom_text_repel():","code":"library(ggrepel) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text() + labs(title = \"geom_text()\") p2 <- p + geom_text_repel() + labs(title = \"geom_text_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Examples","text":"ggrepel available CRAN: latest development version may new features, can get GitHub:","code":"install.packages(\"ggrepel\") # Use the devtools package # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"options","dir":"Articles","previous_headings":"","what":"Options","title":"Examples","text":"Options allow us change behavior ggrepel fit needs figure. global options affect text labels, can vectors length data, like nudge_x nudge_y.","code":""},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"aesthetics","dir":"Articles","previous_headings":"","what":"Aesthetics","title":"Examples","text":"Aesthetics parameters can mapped data geom_text_repel(mapping = aes(...)). ggrepel provides aesthetics geom_text_repel geom_label_repel available geom_text() geom_label(), also provides unique ggrepel. listed . See ggplot2 documentation aesthetic specifications details examples.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"hide-some-of-the-labels","dir":"Articles","previous_headings":"Examples","what":"Hide some of the labels","title":"Examples","text":"Set labels empty string \"\" hide . data points repel non-empty labels. can quickly repel text labels 10,000 data points example . use max.overlaps = Inf ensure text labels discarded, even text label overlaps lots things (e.g. text labels data points).","code":"set.seed(42) dat2 <- subset(mtcars, wt > 3 & wt < 4) # Hide all of the text labels. dat2$car <- \"\" # Let's just label these items. ix_label <- c(2, 3, 14) dat2$car[ix_label] <- rownames(dat2)[ix_label] ggplot(dat2, aes(wt, mpg, label = car)) + geom_text_repel() + geom_point(color = ifelse(dat2$car == \"\", \"grey50\", \"red\")) set.seed(42) dat3 <- rbind( data.frame( wt = rnorm(n = 10000, mean = 3), mpg = rnorm(n = 10000, mean = 19), car = \"\" ), dat2[,c(\"wt\", \"mpg\", \"car\")] ) ggplot(dat3, aes(wt, mpg, label = car)) + geom_point(data = dat3[dat3$car == \"\",], color = \"grey50\") + geom_text_repel(box.padding = 0.5, max.overlaps = Inf) + geom_point(data = dat3[dat3$car != \"\",], color = \"red\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"always-show-all-labels-even-when-they-have-too-many-overlaps","dir":"Articles","previous_headings":"Examples","what":"Always show all labels, even when they have too many overlaps","title":"Examples","text":"text labels discarded overlap many things (default limit 10). , text label overlaps 10 text labels data points, discarded. can expect see warning data points labeled due many overlaps. Set max.overlaps = Inf override behavior always show labels, regardless whether text label overlaps many things. Use options(ggrepel.max.overlaps = Inf) set globally entire session. global option can overridden providing max.overlaps argument geom_text_repel().","code":"set.seed(42) n <- 15 dat4 <- data.frame( x = rep(1, length.out = n), y = rep(1, length.out = n), label = letters[1:n] ) # Set it globally: options(ggrepel.max.overlaps = Inf) p1 <- ggplot(dat4, aes(x, y, label = label)) + geom_point() + geom_label_repel(box.padding = 0.5, max.overlaps = 10) + labs(title = \"max.overlaps = 10 (default)\") p2 <- ggplot(dat4, aes(x, y, label = label)) + geom_point() + geom_label_repel(box.padding = 0.5) + labs(title = \"max.overlaps = Inf\") gridExtra::grid.arrange(p1, p2, ncol = 2) ## Warning: ggrepel: 15 unlabeled data points (too many overlaps). Consider ## increasing max.overlaps"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"do-not-repel-labels-from-data-points","dir":"Articles","previous_headings":"Examples","what":"Do not repel labels from data points","title":"Examples","text":"Set point.size = NA prevent label repulsion away data points. Labels still move away away edges plot.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel(point.size = NA)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"do-not-repel-labels-from-plot-panel-edges","dir":"Articles","previous_headings":"Examples","what":"Do not repel labels from plot (panel) edges","title":"Examples","text":"Set xlim ylim Inf -Inf disable repulsion away edges panel. Use NA indicate edge panel. can also disable clipping allow labels go beyond edges panel.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( # Repel away from the left edge, not from the right. xlim = c(NA, Inf), # Do not repel from top or bottom edges. ylim = c(-Inf, Inf) ) set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + coord_cartesian(clip = \"off\") + geom_label_repel(fill = \"white\", xlim = c(-Inf, Inf), ylim = c(-Inf, Inf))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"expand-the-scale-to-make-room-for-labels","dir":"Articles","previous_headings":"Examples","what":"Expand the scale to make room for labels","title":"Examples","text":"Since text labels repel away edges plot panel, might want expand scale give room fit.","code":"set.seed(42) d <- data.frame( x1 = 1, y1 = rnorm(10), x2 = 2, y2 = rnorm(10), lab = state.name[1:10] ) p <- ggplot(d, aes(x1, y1, xend = x2, yend = y2, label = lab, col = lab)) + geom_segment(size = 1) + guides(color = \"none\") + theme(axis.title.x = element_blank()) + geom_text_repel( nudge_x = -0.2, direction = \"y\", hjust = \"right\" ) + geom_text_repel( aes(x2, y2), nudge_x = 0.1, direction = \"y\", hjust = \"left\" ) p p + scale_x_continuous( breaks = 1:2, labels = c(\"Dimension 1\", \"Dimension 2\"), expand = expansion(mult = 0.5) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"always-or-never-draw-line-segments","dir":"Articles","previous_headings":"Examples","what":"Always (or never) draw line segments","title":"Examples","text":"Use min.segment.length = 0 draw line segments, matter short . Use min.segment.length = Inf never draw line segments, matter long .","code":"p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text_repel(min.segment.length = 0, seed = 42, box.padding = 0.5) + labs(title = \"min.segment.length = 0\") p2 <- p + geom_text_repel(min.segment.length = Inf, seed = 42, box.padding = 0.5) + labs(title = \"min.segment.length = Inf\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"make-curved-line-segments-or-arrows","dir":"Articles","previous_headings":"Examples","what":"Make curved line segments or arrows","title":"Examples","text":"line segments can curved geom_curve() ggplot2. segment.curvature = 1 increases right-hand curvature, negative values increase left-hand curvature, 0 makes straight lines segment.ncp = 3 gives 3 control points curve segment.angle = 20 skews curve towards start, values greater 90 skew toward end Setting curvature value near zero gives sharp angle: Set segment.squareto FALSE get oblique curves, segment.inflect TRUE introduce inflection point. Use segment.shape adjust interpolation control points: can use different line types (1, 2, 3, 4, 5, 6). different types arrows. See ggplot2::geom_segment() details.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( nudge_x = .15, box.padding = 0.5, nudge_y = 1, segment.curvature = -0.1, segment.ncp = 3, segment.angle = 20 ) set.seed(42) cars <- c(\"Volvo 142E\", \"Merc 230\") ggplot(dat) + aes(wt, mpg, label = ifelse(car %in% cars, car, \"\")) + geom_point(color = \"red\") + geom_text_repel( point.padding = 0.2, nudge_x = .15, nudge_y = .5, segment.curvature = -1e-20, arrow = arrow(length = unit(0.015, \"npc\")) ) + theme(legend.position = \"none\") set.seed(42) cars_subset <- head(mtcars, 5) cars_subset$car <- rownames(cars_subset) cars_subset_curves <- cars_subset[rep(seq_len(nrow(cars_subset)), times = 4), ] cars_subset_curves$square <- rep(c(TRUE, FALSE), each = nrow(cars_subset) * 2) cars_subset_curves$inflect <- rep(c(TRUE, FALSE, TRUE, FALSE), each = nrow(cars_subset)) ggplot(cars_subset_curves, aes(y = wt, x = 1, label = car)) + facet_grid(square ~ inflect, labeller = labeller(.default = label_both)) + geom_point(color = \"red\") + ylim(1, 4.5) + xlim(1, 1.375) + geom_text_repel( aes( segment.square = square, segment.inflect = inflect, ), force = 0.5, nudge_x = 0.15, direction = \"y\", hjust = 0, segment.size = 0.2, segment.curvature = -0.1 ) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) set.seed(42) cars_subset_shapes <- cars_subset[rep(seq_len(nrow(cars_subset)), times = 5), ] cars_subset_shapes$shape <- rep(c(-1, -0.5, 0, 0.5, 1), each = nrow(cars_subset)) ggplot(cars_subset_shapes, aes(y = wt, x = 1, label = car)) + facet_wrap('shape', labeller = labeller(.default = label_both), ncol = 1) + geom_point(color = \"red\") + ylim(1, 4.5) + xlim(1, 1.375) + geom_text_repel( aes( segment.shape = shape ), force = 0.5, nudge_x = 0.25, direction = \"y\", hjust = 0, segment.size = 0.2, segment.curvature = -0.6, segment.angle = 45, segment.ncp = 2, segment.square = FALSE, segment.inflect = TRUE ) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) set.seed(42) cars <- c(\"Volvo 142E\", \"Merc 230\") ggplot(dat, aes(wt, mpg, label = ifelse(car %in% cars, car, \"\"))) + geom_point(color = \"red\") + geom_text_repel( point.padding = 0.2, nudge_x = .15, nudge_y = .5, segment.linetype = 6, segment.curvature = -1e-20, arrow = arrow(length = unit(0.015, \"npc\")) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"repel-labels-from-data-points-with-different-sizes","dir":"Articles","previous_headings":"Examples","what":"Repel labels from data points with different sizes","title":"Examples","text":"can use continuous_scale() function ggplot2. allows us specify single scale applies multiple aesthetics. ggrepel, want apply single size scale two aesthetics: size, tells ggplot2 size points draw plot point.size, tells ggrepel point size, can position text labels away example , third size call geom_text_repel() specify font size text labels. geom_text_repel() geom_label_repel()","code":"my_pal <- function(range = c(1, 6)) { force(range) function(x) scales::rescale(x, to = range, from = c(0, 1)) } ggplot(dat, aes(wt, mpg, label = car)) + geom_point(aes(size = cyl), alpha = 0.6) + # data point size continuous_scale( aesthetics = c(\"size\", \"point.size\"), scale_name = \"size\", palette = my_pal(c(2, 15)), guide = guide_legend(override.aes = list(label = \"\")) # hide \"a\" in legend ) + geom_text_repel( aes(point.size = cyl), # data point size size = 5, # font size in the text labels point.padding = 0, # additional padding around each point min.segment.length = 0, # draw all line segments max.time = 1, max.iter = 1e5, # stop after 1 second, or after 100,000 iterations box.padding = 0.3 # additional padding around each text label ) + theme(legend.position = \"right\") my_pal <- function(range = c(1, 6)) { force(range) function(x) scales::rescale(x, to = range, from = c(0, 1)) } ggplot(dat, aes(wt, mpg, label = car)) + geom_label_repel( aes(point.size = cyl), # data point size size = 5, # font size in the text labels point.padding = 0, # additional padding around each point min.segment.length = 0, # draw all line segments max.time = 1, max.iter = 1e5, # stop after 1 second, or after 100,000 iterations box.padding = 0.3 # additional padding around each text label ) + # Put geom_point() after geom_label_repel, so the # legend for geom_point() appears on the top layer. geom_point(aes(size = cyl), alpha = 0.6) + # data point size continuous_scale( aesthetics = c(\"size\", \"point.size\"), scale_name = \"size\", palette = my_pal(c(2, 15)), guide = guide_legend(override.aes = list(label = \"\")) # hide \"a\" in legend ) + theme(legend.position = \"right\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"limit-labels-to-a-specific-area","dir":"Articles","previous_headings":"Examples","what":"Limit labels to a specific area","title":"Examples","text":"Use options xlim ylim constrain labels specific area. Limits specified data coordinates. Use NA lower upper bound particular direction. also use grid::arrow() render segments arrows.","code":"set.seed(42) # All labels should be to the right of 3. x_limits <- c(3, NA) p <- ggplot(dat) + aes( x = wt, y = mpg, label = car, fill = factor(cyl), segment.color = factor(cyl) ) + geom_vline(xintercept = x_limits, linetype = 3) + geom_point() + geom_label_repel( color = \"white\", arrow = arrow( length = unit(0.03, \"npc\"), type = \"closed\", ends = \"first\" ), xlim = x_limits, point.padding = NA, box.padding = 0.1 ) + scale_fill_discrete( name = \"cyl\", # The same color scall will apply to both of these aesthetics. aesthetics = c(\"fill\", \"segment.color\") ) p"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"remove-a-from-the-legend","dir":"Articles","previous_headings":"Examples","what":"Remove “a” from the legend","title":"Examples","text":"Sometimes want remove “” labels legend. can overriding legend aesthetics:","code":"# Don't use \"color\" in the legend. p + guides(fill = guide_legend(override.aes = aes(color = NA))) # Or set the label to the empty string \"\" (or any other string). p + guides(fill = guide_legend(override.aes = aes(label = \"\")))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"align-labels-on-the-top-or-bottom-edge","dir":"Articles","previous_headings":"Examples","what":"Align labels on the top or bottom edge","title":"Examples","text":"Use hjust justify text neatly: hjust = 0 left-align hjust = 0.5 center hjust = 1 right-align Sometimes labels align perfectly. Try using direction = \"x\" limit label movement x-axis (left right) direction = \"y\" limit movement y-axis (). default direction = \"\". Also try using xlim() ylim() increase size plotting area labels fit comfortably. Align text vertically nudge_y allow labels move horizontally direction = \"x\":","code":"set.seed(42) ggplot(mtcars, aes(x = wt, y = 1, label = rownames(mtcars))) + geom_point(color = \"red\") + geom_text_repel( force_pull = 0, # do not pull toward data points nudge_y = 0.05, direction = \"x\", angle = 90, hjust = 0, segment.size = 0.2, max.iter = 1e4, max.time = 1 ) + xlim(1, 6) + ylim(1, 0.8) + theme( axis.line.y = element_blank(), axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.title.y = element_blank() ) set.seed(42) dat <- mtcars dat$car <- rownames(dat) ggplot(dat, aes(qsec, mpg, label = car)) + geom_text_repel( data = subset(dat, mpg > 30), nudge_y = 36 - subset(dat, mpg > 30)$mpg, segment.size = 0.2, segment.color = \"grey50\", direction = \"x\" ) + geom_point(color = ifelse(dat$mpg > 30, \"red\", \"black\")) + scale_x_continuous(expand = c(0.05, 0.05)) + scale_y_continuous(limits = c(NA, 36))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"align-labels-on-the-left-or-right-edge","dir":"Articles","previous_headings":"Examples","what":"Align labels on the left or right edge","title":"Examples","text":"Set direction “y” try hjust 0.5, 0, 1: Align text horizontally nudge_x hjust, allow labels move vertically direction = \"y\":","code":"set.seed(42) p <- ggplot(mtcars, aes(y = wt, x = 1, label = rownames(mtcars))) + geom_point(color = \"red\") + ylim(1, 5.5) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) p1 <- p + xlim(1, 1.375) + geom_text_repel( force = 0.5, nudge_x = 0.15, direction = \"y\", hjust = 0, segment.size = 0.2 ) + ggtitle(\"hjust = 0\") p2 <- p + xlim(1, 1.375) + geom_text_repel( force = 0.5, nudge_x = 0.2, direction = \"y\", hjust = 0.5, segment.size = 0.2 ) + ggtitle(\"hjust = 0.5 (default)\") p3 <- p + xlim(0.25, 1) + scale_y_continuous(position = \"right\") + geom_text_repel( force = 0.5, nudge_x = -0.25, direction = \"y\", hjust = 1, segment.size = 0.2 ) + ggtitle(\"hjust = 1\") gridExtra::grid.arrange(p1, p2, p3, ncol = 3) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) ggplot(dat, aes(wt, mpg, label = car)) + geom_text_repel( data = subset(dat, wt > 3), nudge_x = 3.5 - subset(dat, wt > 3)$wt, segment.size = 0.2, segment.color = \"grey50\", direction = \"y\", hjust = 0 ) + geom_text_repel( data = subset(dat, wt < 3), nudge_x = 2.7 - subset(dat, wt < 3)$wt, segment.size = 0.2, segment.color = \"grey50\", direction = \"y\", hjust = 1 ) + scale_x_continuous( breaks = c(2.5, 2.75, 3, 3.25, 3.5), limits = c(2.4, 3.8) ) + geom_point(color = \"red\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"using-ggrepel-with-stat_summary","dir":"Articles","previous_headings":"Examples","what":"Using ggrepel with stat_summary()","title":"Examples","text":"can use stat_summary() geom = \"text_repel\". Note: use ggplot2::stat_summary() ggrepel, prefer position_nudge_repel() instead ggplot2::position_nudge(). position_nudge_repel() function nudges text label’s position, also remembers original position data point.","code":"p <- ggplot(mtcars, aes(factor(cyl), mpg)) + stat_summary( fill = \"gray90\", colour = \"black\", fun = \"mean\", geom = \"col\" ) p1 <- p + stat_summary( aes(label = round(stat(y))), fun = \"mean\", geom = \"text_repel\", min.segment.length = 0, # always draw segments position = position_nudge(y = -2) ) + labs(title = \"position_nudge()\") p2 <- p + stat_summary( aes(label = round(stat(y))), fun = \"mean\", geom = \"text_repel\", min.segment.length = 0, # always draw segments position = position_nudge_repel(y = -2) ) + labs(title = \"position_nudge_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"justify-multiple-lines-of-text-with-hjust","dir":"Articles","previous_headings":"Examples","what":"Justify multiple lines of text with hjust","title":"Examples","text":"hjust option behave mostly way ggplot2::geom_text().","code":"p <- ggplot() + coord_cartesian(xlim=c(0,1), ylim=c(0,1)) + theme_void() labelInfo <- data.frame( x = c(0.45, 0.55), y = c(0.5, 0.5), g = c( \"I'd like very much to be\\nright justified.\", \"And I'd like to be\\nleft justified.\" ) ) p + geom_text_repel( data = labelInfo, mapping = aes(x, y, label = g), size = 5, hjust = c(1, 0), nudge_x = c(-0.05, 0.05), arrow = arrow(length = unit(2, \"mm\"), ends = \"last\", type = \"closed\") ) p + geom_label_repel( data = labelInfo, mapping = aes(x, y, label = g), size = 5, hjust = c(1, 0), nudge_x = c(-0.05, 0.05), arrow = arrow(length = unit(2, \"mm\"), ends = \"last\", type = \"closed\") )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"label-jittered-points","dir":"Articles","previous_headings":"Examples","what":"Label jittered points","title":"Examples","text":"can also use position functions, like position_quasirandom() ggbeeswarm package Erik Clarke:","code":"mtcars$label <- rownames(mtcars) mtcars$label[mtcars$cyl != 6] <- \"\" # Available since ggplot2 2.2.1 pos <- position_jitter(width = 0.3, seed = 2) ggplot(mtcars, aes(factor(cyl), mpg, color = label != \"\", label = label)) + geom_point(position = pos) + geom_text_repel(position = pos) + theme(legend.position = \"none\") + labs(title = \"position_jitter()\") mtcars$label <- rownames(mtcars) mtcars$label[mtcars$cyl != 6] <- \"\" library(ggbeeswarm) pos <- position_quasirandom() ggplot(mtcars, aes(factor(cyl), mpg, color = label != \"\", label = label)) + geom_point(position = pos) + geom_text_repel(position = pos) + theme(legend.position = \"none\") + labs(title = \"position_quasirandom()\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"label-sf-objects","dir":"Articles","previous_headings":"Examples","what":"Label sf objects","title":"Examples","text":"Currently use geom_text_repel() geom_label_repel() ggplot2::geom_sf plot, probably get error like Error: geom_label_repel requires following missing aesthetics: x y ’s workaround enable ggrepel functions work spatial sf plots like - just need include: stat = \"sf_coordinates\" geom_text|label_repel() call. Thanks Hiroaki Yutani solution.","code":"# thanks to Hiroaki Yutani # https://github.com/slowkow/ggrepel/issues/111#issuecomment-416853013 library(ggplot2) library(sf) nc <- sf::st_read(system.file(\"shape/nc.shp\", package=\"sf\"), quiet = TRUE) ggplot(nc) + geom_sf() + ggrepel::geom_label_repel( data = head(nc), aes(label = NAME, geometry = geometry), stat = \"sf_coordinates\", min.segment.length = 0 )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"shadows-or-glow-under-text-labels","dir":"Articles","previous_headings":"Examples","what":"Shadows (or glow) under text labels","title":"Examples","text":"can place shadows (glow) underneath text label enhance readability text. might useful text labels placed top plot elements. feature uses code shadowtext package Guangchuang Yu.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( color = \"white\", # text color bg.color = \"grey30\", # shadow color bg.r = 0.15 # shadow radius )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"verbose-timing-information","dir":"Articles","previous_headings":"Examples","what":"Verbose timing information","title":"Examples","text":"Use verbose = TRUE see: many iterations physical simulation completed much time elapsed, seconds many overlaps remain unresolved final figure","code":"p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) + geom_point() p + geom_text_repel( verbose = TRUE, seed = 123, max.time = 1, max.iter = Inf, size = 3 ) ## 1.00s elapsed for 147760 iterations, 2 overlaps. Consider increasing 'max.time'."},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"word-cloud","dir":"Articles","previous_headings":"Examples","what":"Word cloud","title":"Examples","text":"Note: ggwordcloud package Erwan Le Pennec creates much better word clouds ggrepel. force option controls strength repulsion. force_pull option controls strength spring pulls text label toward data point. make word cloud, can assign text labels data point origin (0, 0) set force_pull = 0 disable springs.","code":"set.seed(42) ggplot(mtcars) + geom_text_repel( aes( label = rownames(mtcars), size = mpg > 15, colour = factor(cyl), x = 0, y = 0 ), force_pull = 0, # do not pull text toward the point at (0,0) max.time = 0.5, max.iter = 1e5, max.overlaps = Inf, segment.color = NA, point.padding = NA ) + theme_void() + theme(strip.text = element_text(size = 16)) + facet_wrap(~ factor(cyl)) + scale_color_discrete(name = \"Cylinders\") + scale_size_manual(values = c(2, 3)) + theme( strip.text = element_blank(), panel.border = element_rect(size = 0.2, fill = NA) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"polar-coordinates","dir":"Articles","previous_headings":"Examples","what":"Polar coordinates","title":"Examples","text":"","code":"set.seed(42) mtcars$label <- rownames(mtcars) mtcars$label[mtcars$mpg < 25] <- \"\" ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl), label = label)) + coord_polar(theta = \"x\") + geom_point(size = 2) + scale_color_discrete(name = \"cyl\") + geom_text_repel(show.legend = FALSE) + # Don't display \"a\" in the legend. theme_bw(base_size = 18)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"unicode-characters-japanese","dir":"Articles","previous_headings":"Examples","what":"Unicode characters (Japanese)","title":"Examples","text":"","code":"library(ggrepel) set.seed(42) dat <- data.frame( x = runif(32), y = runif(32), label = strsplit( x = \"原文篭毛與美篭母乳布久思毛與美夫君志持此岳尓菜採須兒家吉閑名思毛\", split = \"\" )[[1]] ) # Make sure to choose a font that is installed on your system. my_font <- \"HiraginoSans-W0\" ggplot(dat, aes(x, y, label = label)) + geom_point(size = 2, color = \"red\") + geom_text_repel(size = 8, family = my_font) + ggtitle(\"テスト\") + theme_bw(base_size = 18, base_family = my_font)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"mathematical-expressions","dir":"Articles","previous_headings":"Examples","what":"Mathematical expressions","title":"Examples","text":"","code":"d <- data.frame( x = c(1, 2, 2, 1.75, 1.25), y = c(1, 3, 1, 2.65, 1.25), math = c( NA, \"integral(f(x) * dx, a, b)\", NA, \"lim(f(x), x %->% 0)\", NA ) ) ggplot(d, aes(x, y, label = math)) + geom_point() + geom_label_repel( parse = TRUE, # Parse mathematical expressions. size = 6, box.padding = 2 )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"animation","dir":"Articles","previous_headings":"Examples","what":"Animation","title":"Examples","text":"","code":"# This chunk of code will take a minute or two to run. library(ggrepel) library(animation) plot_frame <- function(n) { set.seed(42) p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) + geom_text_repel( size = 5, force = 1, max.iter = n ) + geom_point(color = \"red\") + # theme_minimal(base_size = 16) + labs(title = n) print(p) } xs <- ceiling(1.18^(1:52)) # xs <- ceiling(1.4^(1:26)) xs <- c(xs, rep(xs[length(xs)], 15)) # plot(xs) saveGIF( lapply(xs, function(i) { plot_frame(i) }), interval = 0.15, ani.width = 800, ani.heigth = 600, movie.name = \"animated.gif\" )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"source-code","dir":"Articles","previous_headings":"","what":"Source code","title":"Examples","text":"View source code vignette GitHub.","code":""},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Examples","text":"","code":"sessionInfo() ## R version 4.2.3 (2023-03-15) ## Platform: aarch64-apple-darwin20 (64-bit) ## Running under: macOS Ventura 13.4 ## ## Matrix products: default ## BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib ## ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] pkgdown_2.0.7 glue_1.6.2 rvest_1.0.3 sf_1.0-12 ## [5] ggbeeswarm_0.7.2 ggrepel_0.9.5 ggplot2_3.4.4 gridExtra_2.3 ## [9] knitr_1.43 ## ## loaded via a namespace (and not attached): ## [1] beeswarm_0.4.0 tidyselect_1.2.0 xfun_0.39 bslib_0.5.0 ## [5] purrr_1.0.1 colorspace_2.1-0 vctrs_0.6.5 generics_0.1.3 ## [9] htmltools_0.5.5 yaml_2.3.7 utf8_1.2.4 rlang_1.1.2 ## [13] e1071_1.7-13 jquerylib_0.1.4 pillar_1.9.0 withr_2.5.2 ## [17] DBI_1.1.3 lifecycle_1.0.4 stringr_1.5.0 munsell_0.5.0 ## [21] gtable_0.3.4 ragg_1.2.5 codetools_0.2-19 memoise_2.0.1 ## [25] evaluate_0.21 labeling_0.4.3 fastmap_1.1.1 vipor_0.4.5 ## [29] class_7.3-21 fansi_1.0.5 highr_0.10 Rcpp_1.0.11 ## [33] KernSmooth_2.23-20 scales_1.3.0 classInt_0.4-9 cachem_1.0.8 ## [37] desc_1.4.2 jsonlite_1.8.7 farver_2.1.1 systemfonts_1.0.4 ## [41] fs_1.6.2 textshaping_0.3.6 digest_0.6.31 stringi_1.7.12 ## [45] dplyr_1.1.2 grid_4.2.3 rprojroot_2.0.3 cli_3.6.1 ## [49] tools_4.2.3 magrittr_2.0.3 sass_0.4.6 proxy_0.4-27 ## [53] tibble_3.2.1 pkgconfig_2.0.3 xml2_1.3.4 httr_1.4.6 ## [57] rmarkdown_2.23 R6_2.5.1 units_0.8-2 compiler_4.2.3"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Getting started with ggrepel","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area (panel). Let’s compare geom_text() geom_text_repel():","code":"library(ggrepel) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text() + labs(title = \"geom_text()\") p2 <- p + geom_text_repel() + labs(title = \"geom_text_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting started with ggrepel","text":"ggrepel available CRAN: latest development version may new features, can get GitHub:","code":"install.packages(\"ggrepel\") # Use the devtools package # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"usage","dir":"Articles","previous_headings":"","what":"Usage","title":"Getting started with ggrepel","text":"See examples page learn use ggrepel project.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ggforce","dir":"Articles","previous_headings":"R","what":"ggforce","title":"Related work","text":"Annotation important storytelling, ggforce provides family geoms makes easy draw attention , describe, features plot. work way, differ way enclose area want draw attention .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"directlabels","dir":"Articles","previous_headings":"R","what":"directlabels","title":"Related work","text":"extensible framework automatically placing direct labels onto multicolor ‘lattice’ ‘ggplot2’ plots. Label positions described using Positioning Methods can re-used across several different plots. heuristics examining “trellis” “ggplot” objects inferring appropriate Positioning Method.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ggwordcloud","dir":"Articles","previous_headings":"R","what":"ggwordcloud","title":"Related work","text":"ggwordcloud provides word cloud text geom ggplot2. placement algorithm implemented C++ hybrid one wordcloud one wordcloud2.js. cloud can grow according shape stay within mask. size aesthetic used either control font size printed area words. ggwordcloud also supports arbitrary text rotation. faceting scheme ggplot2 can also used. ggwordcloud package implements spiraling algorithm prevent text labels overlapping .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"wordcloud","dir":"Articles","previous_headings":"R","what":"wordcloud","title":"Related work","text":"Pretty word clouds. wordcloud package implements spiraling algorithm prevent text labels overlapping .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ffield","dir":"Articles","previous_headings":"R","what":"FField","title":"Related work","text":"Force field simulation interaction set points. useful placing text labels graphs, scatterplots. found functions FField package ideal repelling overlapping rectangles, wrote . See gist examples use wordcloud FField packages ggplot2.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"vega-label","dir":"Articles","previous_headings":"Javascript","what":"vega-label","title":"Related work","text":"Fast Flexible Overlap Detection Chart Labeling Occupancy Bitmaps Chanwut Kittivorawang, Dominik Moritz, Kanit Wongsuphasawat, Jeffrey Heer http://idl.cs.washington.edu/papers/fast-labels/","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3-labeler","dir":"Articles","previous_headings":"Javascript","what":"D3-Labeler","title":"Related work","text":"D3 plug-automatic label placement using simulated annealing Evan Wang’s plugin extends D3 v3. also described approach paper.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3fc-label-layout","dir":"Articles","previous_headings":"Javascript","what":"d3fc-label-layout","title":"Related work","text":"D3 layout places labels avoiding overlaps, strategies including simulated annealing, greedy strategy removes overlapping labels. Colin Eberhardt’s implementation D3 v4.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3-voronoi-labels","dir":"Articles","previous_headings":"Javascript","what":"d3-voronoi-labels","title":"Related work","text":"Voronoi tessellation can assist labeling scatterplots. area Voronoi cell associated point determines whether point labeled: points larger cells tend room accommodate labels.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"adjusttext","dir":"Articles","previous_headings":"Python","what":"adjustText","title":"Related work","text":"small library automatically adjusting text position matplotlib plots minimize overlaps. Ilya Flyamer’s Python library extends matplotlib.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"an-efficient-algorithm-for-scatter-chart-labelingaaai","dir":"Articles","previous_headings":"Academic Papers","what":"An Efficient Algorithm for Scatter Chart Labeling","title":"Related work","text":"Sebastian Theophil, Arno Schödl paper presents efficient algorithm new variation point feature labeling problem. goal position largest number point labels intersect points. First present algorithm using greedy algorithm limited lookahead. present algorithm iteratively regroups labels, calling first algorithm group, thereby identifying close optimal labeling order. presented algorithm used commercial product label charts, evaluation shows produces results far superior labeling algorithms. might good start revision ggrepel.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"chapter-15--labeling-algorithmsbrown","dir":"Articles","previous_headings":"Academic Papers","what":"Chapter 15. Labeling Algorithms","title":"Related work","text":"Konstantinos G. Kakoulis, Ioannis G. Tollis important aspect information visualization automatic placement text symbol labels corresponding graphical features drawings maps. Labels textual descriptions convey information clarify meaning complex structures presented graphical form. automatic label placement problem identified important research area ACM Computational Geometry Task Force [C +99]. applications many areas including cartography [RMM+95], geographic information systems [Fre91], graph drawing [DETT99]. Handbook Graph Drawing Visualization, Roberto Tamassia (Editor), CRC Press, June 24, 2013.","code":""},{"path":"https://ggrepel.slowkow.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Kamil Slowikowski. Author, maintainer. Alicia Schep. Contributor. Sean Hughes. Contributor. Trung Kien Dang. Contributor. Saulius Lukauskas. Contributor. Jean-Olivier Irisson. Contributor. Zhian N Kamvar. Contributor. Thompson Ryan. Contributor. Dervieux Christophe. Contributor. Yutani Hiroaki. Contributor. Pierre Gramme. Contributor. Amir Masoud Abdol. Contributor. Malcolm Barrett. Contributor. Robrecht Cannoodt. Contributor. Michał Krassowski. Contributor. Michael Chirico. Contributor. Pedro Aphalo. Contributor. Francis Barton. Contributor.","code":""},{"path":"https://ggrepel.slowkow.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Slowikowski K (2024). ggrepel: Automatically Position Non-Overlapping Text Labels 'ggplot2'. https://ggrepel.slowkow.com/, https://github.com/slowkow/ggrepel.","code":"@Manual{, title = {ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'}, author = {Kamil Slowikowski}, year = {2024}, note = {https://ggrepel.slowkow.com/, https://github.com/slowkow/ggrepel}, }"},{"path":"https://ggrepel.slowkow.com/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"ggrepel: An R package","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area.","code":"library(ggrepel) ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) + geom_text_repel() + geom_point(color = 'red') + theme_classic(base_size = 16)"},{"path":"https://ggrepel.slowkow.com/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"ggrepel: An R package","text":"","code":"# The easiest way to get ggrepel is to install it from CRAN: install.packages(\"ggrepel\") # Or get the latest development version from GitHub: # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/index.html","id":"getting-help","dir":"","previous_headings":"","what":"Getting help","title":"ggrepel: An R package","text":"Check examples learn use ggrepel project. See collection related work similar R packages, Python packages, . issue ggrepel ggplot2, someone might already experienced . Try searching web, create new post: RStudio community active forum RStudio R users. Stack Overflow lots questions answers ggplot2 ggrepel.","code":""},{"path":"https://ggrepel.slowkow.com/index.html","id":"examples","dir":"","previous_headings":"","what":"Examples","title":"ggrepel: An R package","text":"Click one 22 images view source code figure:","code":""},{"path":"https://ggrepel.slowkow.com/index.html","id":"thanks","dir":"","previous_headings":"","what":"Thanks","title":"ggrepel: An R package","text":"Thanks everyone contributed pull requests, opened issues, asked questions, shared examples! thanks Allison Horst beautiful artwork!","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":null,"dir":"Reference","previous_headings":"","what":"Repulsive textual annotations. — geom_label_repel","title":"Repulsive textual annotations. — geom_label_repel","text":"geom_text_repel adds text directly plot. geom_label_repel draws rectangle underneath text, making easier read. text labels repel away away data points.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Repulsive textual annotations. — geom_label_repel","text":"","code":"geom_label_repel( mapping = NULL, data = NULL, stat = \"identity\", position = \"identity\", parse = FALSE, ..., box.padding = 0.25, label.padding = 0.25, point.padding = 1e-06, label.r = 0.15, label.size = 0.25, min.segment.length = 0.5, arrow = NULL, force = 1, force_pull = 1, max.time = 0.5, max.iter = 10000, max.overlaps = getOption(\"ggrepel.max.overlaps\", default = 10), nudge_x = 0, nudge_y = 0, xlim = c(NA, NA), ylim = c(NA, NA), na.rm = FALSE, show.legend = NA, direction = c(\"both\", \"y\", \"x\"), seed = NA, verbose = FALSE, inherit.aes = TRUE ) geom_text_repel( mapping = NULL, data = NULL, stat = \"identity\", position = \"identity\", parse = FALSE, ..., box.padding = 0.25, point.padding = 1e-06, min.segment.length = 0.5, arrow = NULL, force = 1, force_pull = 1, max.time = 0.5, max.iter = 10000, max.overlaps = getOption(\"ggrepel.max.overlaps\", default = 10), nudge_x = 0, nudge_y = 0, xlim = c(NA, NA), ylim = c(NA, NA), na.rm = FALSE, show.legend = NA, direction = c(\"both\", \"y\", \"x\"), seed = NA, verbose = FALSE, inherit.aes = TRUE )"},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Repulsive textual annotations. — geom_label_repel","text":"mapping Set aesthetic mappings created aes aes_. specified inherit.aes = TRUE (default), combined default mapping top level plot. need supply mapping mapping defined plot. data data frame. specified, overrides default data frame defined top level plot. stat statistical transformation use data layer, string. position Position adjustment, either string, result call position adjustment function. parse TRUE, labels parsed expressions displayed described ?plotmath ... arguments passed layer. three types arguments can use : Aesthetics: set aesthetic fixed value, like colour = \"red\" size = 3. arguments layer, example override default stat associated layer. arguments passed stat. box.padding Amount padding around bounding box, unit number. Defaults 0.25. (Default unit lines, units can specified passing unit(x, \"units\")). label.padding Amount padding around label, unit number. Defaults 0.25. (Default unit lines, units can specified passing unit(x, \"units\")). point.padding Amount padding around labeled point, unit number. Defaults 0. (Default unit lines, units can specified passing unit(x, \"units\")). label.r Radius rounded corners, unit number. Defaults 0.15. (Default unit lines, units can specified passing unit(x, \"units\")). label.size Size label border, mm. min.segment.length Skip drawing segments shorter , unit number. Defaults 0.5. (Default unit lines, units can specified passing unit(x, \"units\")). arrow specification arrow heads, created arrow force Force repulsion overlapping text labels. Defaults 1. force_pull Force attraction text label corresponding data point. Defaults 1. max.time Maximum number seconds try resolve overlaps. Defaults 0.5. max.iter Maximum number iterations try resolve overlaps. Defaults 10000. max.overlaps Exclude text labels overlap many things. Defaults 10. nudge_x, nudge_y Horizontal vertical adjustments nudge starting position text label. units nudge_x nudge_y data units x-axis y-axis. xlim, ylim Limits x y axes. Text labels constrained limits. default, text labels constrained entire plot area. na.rm FALSE (default), removes missing values warning. TRUE silently removes missing values. show.legend logical. layer included legends? NA, default, includes aesthetics mapped. FALSE never includes, TRUE always includes. direction \"\", \"x\", \"y\" -- direction adjust position labels seed Random seed passed set.seed. Defaults NA, means set.seed called. verbose TRUE, diagnostics repel algorithm printed inherit.aes FALSE, overrides default aesthetics, rather combining . useful helper functions define data aesthetics inherit behaviour default plot specification, e.g. borders.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Repulsive textual annotations. — geom_label_repel","text":"geoms based geom_text geom_label. See documentation functions details. Differences functions noted . Text labels height width, physical units, data units. amount space occupy plot constant data units: resize plot, labels stay size, size axes changes. text labels repositioned resizing plot.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"geom-label-repel","dir":"Reference","previous_headings":"","what":"geom_label_repel","title":"Repulsive textual annotations. — geom_label_repel","text":"Currently geom_label_repel support rot argument considerably slower geom_text_repel. fill aesthetic controls background colour label.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"alignment-with-hjust-or-vjust","dir":"Reference","previous_headings":"","what":"Alignment with hjust or vjust","title":"Repulsive textual annotations. — geom_label_repel","text":"arguments hjust vjust supported, control initial positioning, repulsive forces may disrupt alignment. Alignment hjust preserved labels move using direction=\"y\". vjust, use direction=\"x\".","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Repulsive textual annotations. — geom_label_repel","text":"","code":"p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) + geom_point() # Avoid overlaps by repelling text labels p + geom_text_repel() # Labels with background p + geom_label_repel() #> Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider increasing max.overlaps if (FALSE) { p + geom_text_repel(family = \"Times New Roman\", box.padding = 0.5) # Add aesthetic mappings p + geom_text_repel(aes(alpha=wt, size=mpg)) p + geom_label_repel(aes(fill=factor(cyl)), colour=\"white\", segment.colour=\"black\") # Draw all line segments p + geom_text_repel(min.segment.length = 0) # Omit short line segments (default behavior) p + geom_text_repel(min.segment.length = 0.5) # Omit all line segments p + geom_text_repel(segment.colour = NA) # Repel just the labels and totally ignore the data points p + geom_text_repel(point.size = NA) # Hide some of the labels, but repel from all data points mtcars$label <- rownames(mtcars) mtcars$label[1:15] <- \"\" p + geom_text_repel(data = mtcars, aes(wt, mpg, label = label)) # Nudge the starting positions p + geom_text_repel(nudge_x = ifelse(mtcars$cyl == 6, 1, 0), nudge_y = ifelse(mtcars$cyl == 6, 8, 0)) # Change the text size p + geom_text_repel(aes(size = wt)) # Scale height of text, rather than sqrt(height) p + geom_text_repel(aes(size = wt)) + scale_radius(range = c(3,6)) # You can display expressions by setting parse = TRUE. The # details of the display are described in ?plotmath, but note that # geom_text_repel uses strings, not expressions. p + geom_text_repel(aes(label = paste(wt, \"^(\", cyl, \")\", sep = \"\")), parse = TRUE) # Add a text annotation p + geom_text_repel() + annotate( \"text\", label = \"plot mpg vs. wt\", x = 2, y = 15, size = 8, colour = \"red\" ) # Add arrows p + geom_point(colour = \"red\") + geom_text_repel( arrow = arrow(length = unit(0.02, \"npc\")), box.padding = 1 ) }"},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":null,"dir":"Reference","previous_headings":"","what":"GeomLabelRepel — GeomLabelRepel","title":"GeomLabelRepel — GeomLabelRepel","text":"package contains extra geoms ggplot2.","code":""},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"GeomLabelRepel — GeomLabelRepel","text":"Please see help pages listed : geom_text_repel geom_label_repel Also see vignette usage examples: browseVignettes(\"ggrepel\") Please report issues suggest improvements Github: https://github.com/slowkow/ggrepel","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"GeomLabelRepel — GeomLabelRepel","text":"Maintainer: Kamil Slowikowski kslowikowski@gmail.com (ORCID) contributors: Alicia Schep (ORCID) [contributor] Sean Hughes (ORCID) [contributor] Trung Kien Dang (ORCID) [contributor] Saulius Lukauskas [contributor] Jean-Olivier Irisson (ORCID) [contributor] Zhian N Kamvar (ORCID) [contributor] Thompson Ryan (ORCID) [contributor] Dervieux Christophe (ORCID) [contributor] Yutani Hiroaki [contributor] Pierre Gramme [contributor] Amir Masoud Abdol [contributor] Malcolm Barrett (ORCID) [contributor] Robrecht Cannoodt (ORCID) [contributor] Michał Krassowski (ORCID) [contributor] Michael Chirico (ORCID) [contributor] Pedro Aphalo (ORCID) [contributor]","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":null,"dir":"Reference","previous_headings":"","what":"Nudge labels a fixed distance from points — position_nudge_repel","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"position_nudge_repel useful adjusting starting position text labels repelled data points.","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"","code":"position_nudge_repel(x = 0, y = 0)"},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"x, y Amount horizontal vertical distance move. units data x y axes.","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"","code":"df <- data.frame( x = c(1,3,2,5), y = c(\"a\",\"c\",\"d\",\"c\") ) ggplot(df, aes(x, y)) + geom_point() + geom_text_repel(aes(label = y)) ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, position = position_nudge_repel(x = 0.1, y = 0.15) ) # The values for x and y can be vectors ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, position = position_nudge_repel( x = c(0.1, 0, -0.1, 0), y = c(0.1, 0.2, -0.1, -0.2) ) ) # We can also use geom_text_repel() with arguments nudge_x, nudge_y ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, nudge_x = 0.1, nudge_y = 0.15 ) # The arguments nudge_x, nudge_y also accept vectors ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, nudge_x = c(0.1, 0, -0.1, 0), nudge_y = c(0.1, 0.2, -0.1, -0.2) )"},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.5","text":"Change expect_equal() include tolerance, satisfy CRAN testing. Delete note old (2.2.1) versions ggplot2, thanks @olivroy pull request 246. Add website link DESCRIPTION, thanks @olivroy pull request 241.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-094","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.4","title":"ggrepel 0.9.4","text":"CRAN release: 2023-10-12","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.4","text":"Add min.segment.length options table examples page, thanks @jwhendy mentioning . Add example use ggrepel sf objects, .e. geom_text_repel(..., stat = \"sf_coordinates\"), thanks @francisbarton pull request 236. Use expect_equal(x, y) instead expect_true(identical(x, y)), see issue 242 details.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-093","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.3","title":"ggrepel 0.9.3","text":"CRAN release: 2023-02-03","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-3","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.3","text":"set seed ggrepel::geom_text_repel(seed = 1), longer override seed unrelated code. Thanks @kassambara reporting issue 228.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-092","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.2","title":"ggrepel 0.9.2","text":"CRAN release: 2022-11-06","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-2","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.2","text":"Fix compiler errors C++ expressions like v[] = {0,0} arise versions clang compiler. Thanks @Krascal @vrognas reporting issue 184. Fix warning CRAN warning: use bitwise '&' boolean operands","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.2","text":"Change internal column names, ggrepel::position_nudge_repel() can now used ggplot2::geom_text(). also allow us use new nudge functions ggpp package @aphalo. Thanks @aphalo pull request 193. Improve handling justification angle different zero ggrepel::geom_text_repel() pull request 196.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-091-2021-01-09","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.1 2021-01-09","title":"ggrepel 0.9.1 2021-01-09","text":"CRAN release: 2021-01-15","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-1","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.1 2021-01-09","text":"Fix label positions (geom_label_repel()). plot look OK ggrepel 0.8.2, incorrect ggrepel 0.9.0. Thanks Ben Baumer (@beanumber) reporting issue 182. Fix bug caused R crash (Windows, Linux macOS) specific code examples. Thanks Pedro Aphalo (@aphalo) reporting issue 179 testing patched code.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-090-2020-12-14","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.0 2020-12-14","title":"ggrepel 0.9.0 2020-12-14","text":"CRAN release: 2020-12-16","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.0 2020-12-14","text":"Points can different sizes. Repel text labels large points small points. New examples vignette show . See discussion feature issue 83. New parameter max.overlaps stops ggrepel trying label overcrowded data points. default setting max.overlaps = 10, text labels overlap 10 things (points labels) excluded calculations rendering. course, can set max.overlaps = Inf restore behavior ggrepel 0.8.1. See [issue 48] discussion. can also use option(ggrepel.max.overlaps = Inf) disable new functionality display labels, regardless many overlaps. Add examples vignette ggplot2::position_jitter() ggbeeswarm::position_quasirandom() Line segments can now curved (#131, @malcolmbarrett). Add examples vignette showing different options. Add support new aesthetics: segment.size segment.colour segment.alpha segment.curvature segment.angle segment.ncp Add max.time option limit number seconds spent trying position text labels. Add verbose option show timing information: seconds elapse, iteration count, number remaining overlaps (thanks @MichaelChirico #159). Add bg.color bg.r aesthetics geom_text() display shadows behind text labels. Thanks @rcannood adding feature pull request 142.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.9.0 2020-12-14","text":"Line segments color text default (#164, @lishinkou). Text justification multi-line text labels working expected. Thanks @johnhenrypezzuto @phalteman comments issue 137. Put text labels top line segments (@kiendang). fixes issue 35, line segments sometimes appear top text. Thanks Paul Murrell (@pmur002) notifying us use .unit(x) instead class(x) == \"unit\" issue 141. future-proof ggrepel new versions grid package. Fix way xlim = c(-Inf, Inf) treated. Thanks @thomasp85 pointing bug issue 136. segment.shape segment.square segment.squareShape segment.inflect","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-081-2019-05-07","dir":"Changelog","previous_headings":"","what":"ggrepel 0.8.1 2019-05-07","title":"ggrepel 0.8.1 2019-05-07","text":"CRAN release: 2019-05-07","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-8-1","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.8.1 2019-05-07","text":"Fix heap buffer overflow causes R crash. See issue 115. Thanks Brodie Gaslam (@brodieG) helping setup environment reproduce bug system.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-080-2018-05-09","dir":"Changelog","previous_headings":"","what":"ggrepel 0.8.0 2018-05-09","title":"ggrepel 0.8.0 2018-05-09","text":"CRAN release: 2018-05-09","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.8.0 2018-05-09","text":"Fix geom_label_repel(..., point.padding=NA). Reported @mlell issue 104.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-7-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.7.3 2018-02-09","text":"Add support position parameter. See issue 69. allows us add text labels points positioned position_jitter(), position_dodge(), position_jitterdodge(), etc. Please note feature work ggplot2 2.2.1 older.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-7-2","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.7.2 2018-01-14","text":"Thanks @AliciaSchep @aphalo Fix warning hjust. See issue 93. Fix bug subset points labeled geom_label_repel. See issue 92.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-7-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.7.1 2017-11-18","text":"Thanks @AliciaSchep Add support hjust vjust parameters. See issue 69. Also see new examples vignette. Add code avoid intersecting line segments. See issue 34.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-070-2017-09-28","dir":"Changelog","previous_headings":"","what":"ggrepel 0.7.0 2017-09-28","title":"ggrepel 0.7.0 2017-09-28","text":"CRAN release: 2017-09-29","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-7-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.7.0 2017-09-28","text":"Fix intersection lines rectangles, reproduce aesthetically pleasant behavior version 0.6.5. improvement sloppy implementation introduced 0.6.8. See commit 28633d information.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-12","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.12 2017-07-16","text":"Reproduce identical plots using seed = 1 set seed geom_text_repel() geom_label_repel(). default, seed set. improvement sloppy implementation introduced 0.6.2. See issue 33 issue 73 discussion feature. Thanks Pierre Gramme reminding via email.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-11","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.11 2017-07-08","text":"Thanks @seaaan Allow certain parameters passed numbers unit() instead units. See issue 79.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-10","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.10 2017-03-07","text":"Thanks @zkamvar Fix crash plots specify xlim ylim. See pull 74.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-9","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.9 2017-03-07","text":"Fix crash plots facet_wrap facet_grid labeled points. Thanks @pcroteau pull 70.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-8","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.8 2017-02-12","text":"Constrain repulsion force x-axis “x” y-axis “y” direction geom_text_repel() geom_label_repel(). Thanks @AliciaSchep pull 68.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-7","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.7 2017-01-09","text":"Constrain text labels specific areas plot xlim ylim geom_text_repel() geom_label_repel(). Thanks @lukauskas pull 67.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.6 2016-11-28","text":"Mathematical expressions labels parse = TRUE geom_text_repel() geom_label_repel(). Thanks @fawda123 issue 60.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-065-2016-11-22","dir":"Changelog","previous_headings":"","what":"ggrepel 0.6.5 2016-11-22","title":"ggrepel 0.6.5 2016-11-22","text":"CRAN release: 2016-11-24","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.5 2016-11-22","text":"Thanks @jiho : changed alpha geom_label_repel() control text, label background, label border, segment. Allow segment.colour well segment.color. default, map text color text alpha segment color unless overridden. Call scales::alpha() instead alpha().","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.4 2016-11-08","text":"Fix bug caused ggrepel fail polar coordinates coord_polar(). See issue 56.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-063-2016-10-14","dir":"Changelog","previous_headings":"","what":"ggrepel 0.6.3 2016-10-14","title":"ggrepel 0.6.3 2016-10-14","text":"CRAN release: 2016-10-20","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.3 2016-10-14","text":"Use point.padding=NA ignore data points repulsion calculations.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-2","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.2 2016-10-06","text":"Stop labels escaping plot boundaries instead applying force boundary. Call set.seed within geom_text_repel() geom_label_repel() allow recreating identical plots. Thanks @erikor issue 33.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.2 2016-10-06","text":"Add min.segment.length geom_text_repel() geom_label_repel().","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.1 2016-10-04","text":"Tweak repel_boxes.cpp. Dampen forces tune labels move. result looks better, least examples vignette.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.0 2016-10-03","text":"draw labels empty strings. label empty string, text shown, segment drawn, corresponding data point repel labels. See issue 51. Add segment.alpha option geom_text_repel() geom_label_repel(). Implement angle aesthetic geom_text_repel(), way done ggplot2 geom_text(). Move nudge_x nudge_y aesthetics function aes(). makes ggrepel consistent ggplot2 functions geom_text() geom_label(). Backwards incompatible 0.5.1. Restore segment.color option geom_text_repel() geom_label_repel(). Tweak repel_boxes.cpp. weight repulsion force ratios bounding box heights widths. seems perform better, especially rotating text labels.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-051-2016-02-22","dir":"Changelog","previous_headings":"","what":"ggrepel 0.5.1 2016-02-22","title":"ggrepel 0.5.1 2016-02-22","text":"Optimize C++ code reducing number calls rnorm().","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-05-2016-02-08","dir":"Changelog","previous_headings":"","what":"ggrepel 0.5 2016-02-08","title":"ggrepel 0.5 2016-02-08","text":"CRAN release: 2016-02-08 First push CRAN.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-6","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.6 2016-02-07","text":"Tweak point.padding users can configure far labels pushed away data points.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.5 2016-02-06","text":"Optimize C++ code 2.5X speed improvment. Delete unnecessary .Rd files.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-044-2016-02-05","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4.4 2016-02-05","title":"ggrepel 0.4.4 2016-02-05","text":"FIXES Fix bug line segment data point points origin (0,0) instead text label.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.4 2016-02-05","text":"Automatically recompute repulsion labels resizing plot.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.3 2016-01-18","text":"Change distance segment label geom_label_repel(). Now gap end segment label border.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-042-2016-01-15","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4.2 2016-01-15","title":"ggrepel 0.4.2 2016-01-15","text":"FIXES Fix spring_force() never returns NaN.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.2 2016-01-15","text":"Add nudge_x nudge_y better control positioning labels.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.1 2016-01-13","text":"Add arrow parameter allow plotting arrows point labeled data points rather plain line segments. Always draw segments, even labeled point close label. FIXES Fix point.padding horizontal vertical padding calculated correctly. Tweak forces improve layout near borders crowded areas.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-04-2016-01-12","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4 2016-01-12","title":"ggrepel 0.4 2016-01-12","text":"CRAN release: 2016-01-12","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.4 2016-01-12","text":"Fix issue 7. Labels can now placed anywhere plotting area instead limited x y ranges corresponding data points. Fix DESCRIPTION require ggplot2 >= 2.0.0","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4 2016-01-12","text":"Add new parameter point.padding add padding around labeled points. line segment stop reaching coordinates point. text labels also now padded line segment improve legibility. Add volcano plot vignette usage examples. Add Travis continuous integration test R-devel, R-release, R-oldrel. Dampen repulsion force slightly improve algorithm efficiency. Move intersect_line_rectangle() src/repel_boxes.cpp.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-03-2016-01-08","dir":"Changelog","previous_headings":"","what":"ggrepel 0.3 2016-01-08","title":"ggrepel 0.3 2016-01-08","text":"CRAN release: 2016-01-09","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.3 2016-01-08","text":"Remove unused imports: colorspace. Update NAMESPACE new version roxygen. Use spring force attract label point. Change default maximum iterations 10,000 2000. Update man pages. Remove unused code.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.2.0 2016-01-07","text":"Update geom_text_repel() geom_label_repel(). Change label.padding box.padding. Remove unsupported parameters: position nudge_x nudge_y hjust vjust Remove unused imports.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"documentation-0-2-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"ggrepel 0.2.0 2016-01-07","text":"Add roxygen docs functions.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-1-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.1.0 2016-01-05","text":"Add geom_label_repel(). Add fudge width help legends. Add expand=TRUE allow text placed expanded plot area. Add man/ folder. Add links ggplot2 docs vignette. Add unused R implementation repel_boxes(), just reference.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-001-2016-01-04","dir":"Changelog","previous_headings":"","what":"ggrepel 0.0.1 2016-01-04","title":"ggrepel 0.0.1 2016-01-04","text":"Initial release github.","code":""}]
+[{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"summary","dir":"","previous_headings":"","what":"Summary","title":"NA","text":"sentence briefly summarizes issue.","code":""},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"minimal-code-example","dir":"","previous_headings":"","what":"Minimal code example","title":"NA","text":"minimum amount code needed demonstrate issue: image output produced code: IMAGE","code":"ggplot(...) + geom_text_repel(...)"},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"suggestions","dir":"","previous_headings":"","what":"Suggestions","title":"NA","text":"proposal solve issue.","code":""},{"path":"https://ggrepel.slowkow.com/ISSUE_TEMPLATE.html","id":"version-information","dir":"","previous_headings":"","what":"Version information","title":"NA","text":"output sessionInfo() R session:","code":"Paste output here"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Examples","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area (panel). Let’s compare geom_text() geom_text_repel():","code":"library(ggrepel) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text() + labs(title = \"geom_text()\") p2 <- p + geom_text_repel() + labs(title = \"geom_text_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Examples","text":"ggrepel available CRAN: latest development version may new features, can get GitHub:","code":"install.packages(\"ggrepel\") # Use the devtools package # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"options","dir":"Articles","previous_headings":"","what":"Options","title":"Examples","text":"Options allow us change behavior ggrepel fit needs figure. global options affect text labels, can vectors length data, like nudge_x nudge_y.","code":""},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"aesthetics","dir":"Articles","previous_headings":"","what":"Aesthetics","title":"Examples","text":"Aesthetics parameters can mapped data geom_text_repel(mapping = aes(...)). ggrepel provides aesthetics geom_text_repel geom_label_repel available geom_text() geom_label(), also provides unique ggrepel. listed . See ggplot2 documentation aesthetic specifications details examples.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"hide-some-of-the-labels","dir":"Articles","previous_headings":"Examples","what":"Hide some of the labels","title":"Examples","text":"Set labels empty string \"\" hide . data points repel non-empty labels. can quickly repel text labels 10,000 data points example . use max.overlaps = Inf ensure text labels discarded, even text label overlaps lots things (e.g. text labels data points).","code":"set.seed(42) dat2 <- subset(mtcars, wt > 3 & wt < 4) # Hide all of the text labels. dat2$car <- \"\" # Let's just label these items. ix_label <- c(2, 3, 14) dat2$car[ix_label] <- rownames(dat2)[ix_label] ggplot(dat2, aes(wt, mpg, label = car)) + geom_text_repel() + geom_point(color = ifelse(dat2$car == \"\", \"grey50\", \"red\")) set.seed(42) dat3 <- rbind( data.frame( wt = rnorm(n = 10000, mean = 3), mpg = rnorm(n = 10000, mean = 19), car = \"\" ), dat2[,c(\"wt\", \"mpg\", \"car\")] ) ggplot(dat3, aes(wt, mpg, label = car)) + geom_point(data = dat3[dat3$car == \"\",], color = \"grey50\") + geom_text_repel(box.padding = 0.5, max.overlaps = Inf) + geom_point(data = dat3[dat3$car != \"\",], color = \"red\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"always-show-all-labels-even-when-they-have-too-many-overlaps","dir":"Articles","previous_headings":"Examples","what":"Always show all labels, even when they have too many overlaps","title":"Examples","text":"text labels discarded overlap many things (default limit 10). , text label overlaps 10 text labels data points, discarded. can expect see warning data points labeled due many overlaps. Set max.overlaps = Inf override behavior always show labels, regardless whether text label overlaps many things. Use options(ggrepel.max.overlaps = Inf) set globally entire session. global option can overridden providing max.overlaps argument geom_text_repel().","code":"set.seed(42) n <- 15 dat4 <- data.frame( x = rep(1, length.out = n), y = rep(1, length.out = n), label = letters[1:n] ) # Set it globally: options(ggrepel.max.overlaps = Inf) p1 <- ggplot(dat4, aes(x, y, label = label)) + geom_point() + geom_label_repel(box.padding = 0.5, max.overlaps = 10) + labs(title = \"max.overlaps = 10 (default)\") p2 <- ggplot(dat4, aes(x, y, label = label)) + geom_point() + geom_label_repel(box.padding = 0.5) + labs(title = \"max.overlaps = Inf\") gridExtra::grid.arrange(p1, p2, ncol = 2) ## Warning: ggrepel: 15 unlabeled data points (too many overlaps). Consider ## increasing max.overlaps"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"do-not-repel-labels-from-data-points","dir":"Articles","previous_headings":"Examples","what":"Do not repel labels from data points","title":"Examples","text":"Set point.size = NA prevent label repulsion away data points. Labels still move away away edges plot.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel(point.size = NA)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"do-not-repel-labels-from-plot-panel-edges","dir":"Articles","previous_headings":"Examples","what":"Do not repel labels from plot (panel) edges","title":"Examples","text":"Set xlim ylim Inf -Inf disable repulsion away edges panel. Use NA indicate edge panel. can also disable clipping allow labels go beyond edges panel.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( # Repel away from the left edge, not from the right. xlim = c(NA, Inf), # Do not repel from top or bottom edges. ylim = c(-Inf, Inf) ) set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + coord_cartesian(clip = \"off\") + geom_label_repel(fill = \"white\", xlim = c(-Inf, Inf), ylim = c(-Inf, Inf))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"expand-the-scale-to-make-room-for-labels","dir":"Articles","previous_headings":"Examples","what":"Expand the scale to make room for labels","title":"Examples","text":"Since text labels repel away edges plot panel, might want expand scale give room fit.","code":"set.seed(42) d <- data.frame( x1 = 1, y1 = rnorm(10), x2 = 2, y2 = rnorm(10), lab = state.name[1:10] ) p <- ggplot(d, aes(x1, y1, xend = x2, yend = y2, label = lab, col = lab)) + geom_segment(size = 1) + guides(color = \"none\") + theme(axis.title.x = element_blank()) + geom_text_repel( nudge_x = -0.2, direction = \"y\", hjust = \"right\" ) + geom_text_repel( aes(x2, y2), nudge_x = 0.1, direction = \"y\", hjust = \"left\" ) p p + scale_x_continuous( breaks = 1:2, labels = c(\"Dimension 1\", \"Dimension 2\"), expand = expansion(mult = 0.5) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"always-or-never-draw-line-segments","dir":"Articles","previous_headings":"Examples","what":"Always (or never) draw line segments","title":"Examples","text":"Use min.segment.length = 0 draw line segments, matter short . Use min.segment.length = Inf never draw line segments, matter long .","code":"p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text_repel(min.segment.length = 0, seed = 42, box.padding = 0.5) + labs(title = \"min.segment.length = 0\") p2 <- p + geom_text_repel(min.segment.length = Inf, seed = 42, box.padding = 0.5) + labs(title = \"min.segment.length = Inf\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"make-curved-line-segments-or-arrows","dir":"Articles","previous_headings":"Examples","what":"Make curved line segments or arrows","title":"Examples","text":"line segments can curved geom_curve() ggplot2. segment.curvature = 1 increases right-hand curvature, negative values increase left-hand curvature, 0 makes straight lines segment.ncp = 3 gives 3 control points curve segment.angle = 20 skews curve towards start, values greater 90 skew toward end Setting curvature value near zero gives sharp angle: Set segment.squareto FALSE get oblique curves, segment.inflect TRUE introduce inflection point. Use segment.shape adjust interpolation control points: can use different line types (1, 2, 3, 4, 5, 6). different types arrows. See ggplot2::geom_segment() details.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( nudge_x = .15, box.padding = 0.5, nudge_y = 1, segment.curvature = -0.1, segment.ncp = 3, segment.angle = 20 ) set.seed(42) cars <- c(\"Volvo 142E\", \"Merc 230\") ggplot(dat) + aes(wt, mpg, label = ifelse(car %in% cars, car, \"\")) + geom_point(color = \"red\") + geom_text_repel( point.padding = 0.2, nudge_x = .15, nudge_y = .5, segment.curvature = -1e-20, arrow = arrow(length = unit(0.015, \"npc\")) ) + theme(legend.position = \"none\") set.seed(42) cars_subset <- head(mtcars, 5) cars_subset$car <- rownames(cars_subset) cars_subset_curves <- cars_subset[rep(seq_len(nrow(cars_subset)), times = 4), ] cars_subset_curves$square <- rep(c(TRUE, FALSE), each = nrow(cars_subset) * 2) cars_subset_curves$inflect <- rep(c(TRUE, FALSE, TRUE, FALSE), each = nrow(cars_subset)) ggplot(cars_subset_curves, aes(y = wt, x = 1, label = car)) + facet_grid(square ~ inflect, labeller = labeller(.default = label_both)) + geom_point(color = \"red\") + ylim(1, 4.5) + xlim(1, 1.375) + geom_text_repel( aes( segment.square = square, segment.inflect = inflect, ), force = 0.5, nudge_x = 0.15, direction = \"y\", hjust = 0, segment.size = 0.2, segment.curvature = -0.1 ) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) set.seed(42) cars_subset_shapes <- cars_subset[rep(seq_len(nrow(cars_subset)), times = 5), ] cars_subset_shapes$shape <- rep(c(-1, -0.5, 0, 0.5, 1), each = nrow(cars_subset)) ggplot(cars_subset_shapes, aes(y = wt, x = 1, label = car)) + facet_wrap('shape', labeller = labeller(.default = label_both), ncol = 1) + geom_point(color = \"red\") + ylim(1, 4.5) + xlim(1, 1.375) + geom_text_repel( aes( segment.shape = shape ), force = 0.5, nudge_x = 0.25, direction = \"y\", hjust = 0, segment.size = 0.2, segment.curvature = -0.6, segment.angle = 45, segment.ncp = 2, segment.square = FALSE, segment.inflect = TRUE ) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) set.seed(42) cars <- c(\"Volvo 142E\", \"Merc 230\") ggplot(dat, aes(wt, mpg, label = ifelse(car %in% cars, car, \"\"))) + geom_point(color = \"red\") + geom_text_repel( point.padding = 0.2, nudge_x = .15, nudge_y = .5, segment.linetype = 6, segment.curvature = -1e-20, arrow = arrow(length = unit(0.015, \"npc\")) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"repel-labels-from-data-points-with-different-sizes","dir":"Articles","previous_headings":"Examples","what":"Repel labels from data points with different sizes","title":"Examples","text":"can use continuous_scale() function ggplot2. allows us specify single scale applies multiple aesthetics. ggrepel, want apply single size scale two aesthetics: size, tells ggplot2 size points draw plot point.size, tells ggrepel point size, can position text labels away example , third size call geom_text_repel() specify font size text labels. geom_text_repel() geom_label_repel()","code":"my_pal <- function(range = c(1, 6)) { force(range) function(x) scales::rescale(x, to = range, from = c(0, 1)) } ggplot(dat, aes(wt, mpg, label = car)) + geom_point(aes(size = cyl), alpha = 0.6) + # data point size continuous_scale( aesthetics = c(\"size\", \"point.size\"), scale_name = \"size\", palette = my_pal(c(2, 15)), guide = guide_legend(override.aes = list(label = \"\")) # hide \"a\" in legend ) + geom_text_repel( aes(point.size = cyl), # data point size size = 5, # font size in the text labels point.padding = 0, # additional padding around each point min.segment.length = 0, # draw all line segments max.time = 1, max.iter = 1e5, # stop after 1 second, or after 100,000 iterations box.padding = 0.3 # additional padding around each text label ) + theme(legend.position = \"right\") my_pal <- function(range = c(1, 6)) { force(range) function(x) scales::rescale(x, to = range, from = c(0, 1)) } ggplot(dat, aes(wt, mpg, label = car)) + geom_label_repel( aes(point.size = cyl), # data point size size = 5, # font size in the text labels point.padding = 0, # additional padding around each point min.segment.length = 0, # draw all line segments max.time = 1, max.iter = 1e5, # stop after 1 second, or after 100,000 iterations box.padding = 0.3 # additional padding around each text label ) + # Put geom_point() after geom_label_repel, so the # legend for geom_point() appears on the top layer. geom_point(aes(size = cyl), alpha = 0.6) + # data point size continuous_scale( aesthetics = c(\"size\", \"point.size\"), scale_name = \"size\", palette = my_pal(c(2, 15)), guide = guide_legend(override.aes = list(label = \"\")) # hide \"a\" in legend ) + theme(legend.position = \"right\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"limit-labels-to-a-specific-area","dir":"Articles","previous_headings":"Examples","what":"Limit labels to a specific area","title":"Examples","text":"Use options xlim ylim constrain labels specific area. Limits specified data coordinates. Use NA lower upper bound particular direction. also use grid::arrow() render segments arrows.","code":"set.seed(42) # All labels should be to the right of 3. x_limits <- c(3, NA) p <- ggplot(dat) + aes( x = wt, y = mpg, label = car, fill = factor(cyl), segment.color = factor(cyl) ) + geom_vline(xintercept = x_limits, linetype = 3) + geom_point() + geom_label_repel( color = \"white\", arrow = arrow( length = unit(0.03, \"npc\"), type = \"closed\", ends = \"first\" ), xlim = x_limits, point.padding = NA, box.padding = 0.1 ) + scale_fill_discrete( name = \"cyl\", # The same color scall will apply to both of these aesthetics. aesthetics = c(\"fill\", \"segment.color\") ) p"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"remove-a-from-the-legend","dir":"Articles","previous_headings":"Examples","what":"Remove “a” from the legend","title":"Examples","text":"Sometimes want remove “” labels legend. can overriding legend aesthetics:","code":"# Don't use \"color\" in the legend. p + guides(fill = guide_legend(override.aes = aes(color = NA))) # Or set the label to the empty string \"\" (or any other string). p + guides(fill = guide_legend(override.aes = aes(label = \"\")))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"align-labels-on-the-top-or-bottom-edge","dir":"Articles","previous_headings":"Examples","what":"Align labels on the top or bottom edge","title":"Examples","text":"Use hjust justify text neatly: hjust = 0 left-align hjust = 0.5 center hjust = 1 right-align Sometimes labels align perfectly. Try using direction = \"x\" limit label movement x-axis (left right) direction = \"y\" limit movement y-axis (). default direction = \"\". Also try using xlim() ylim() increase size plotting area labels fit comfortably. Align text vertically nudge_y allow labels move horizontally direction = \"x\":","code":"set.seed(42) ggplot(mtcars, aes(x = wt, y = 1, label = rownames(mtcars))) + geom_point(color = \"red\") + geom_text_repel( force_pull = 0, # do not pull toward data points nudge_y = 0.05, direction = \"x\", angle = 90, hjust = 0, segment.size = 0.2, max.iter = 1e4, max.time = 1 ) + xlim(1, 6) + ylim(1, 0.8) + theme( axis.line.y = element_blank(), axis.ticks.y = element_blank(), axis.text.y = element_blank(), axis.title.y = element_blank() ) set.seed(42) dat <- mtcars dat$car <- rownames(dat) ggplot(dat, aes(qsec, mpg, label = car)) + geom_text_repel( data = subset(dat, mpg > 30), nudge_y = 36 - subset(dat, mpg > 30)$mpg, segment.size = 0.2, segment.color = \"grey50\", direction = \"x\" ) + geom_point(color = ifelse(dat$mpg > 30, \"red\", \"black\")) + scale_x_continuous(expand = c(0.05, 0.05)) + scale_y_continuous(limits = c(NA, 36))"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"align-labels-on-the-left-or-right-edge","dir":"Articles","previous_headings":"Examples","what":"Align labels on the left or right edge","title":"Examples","text":"Set direction “y” try hjust 0.5, 0, 1: Align text horizontally nudge_x hjust, allow labels move vertically direction = \"y\":","code":"set.seed(42) p <- ggplot(mtcars, aes(y = wt, x = 1, label = rownames(mtcars))) + geom_point(color = \"red\") + ylim(1, 5.5) + theme( axis.line.x = element_blank(), axis.ticks.x = element_blank(), axis.text.x = element_blank(), axis.title.x = element_blank() ) p1 <- p + xlim(1, 1.375) + geom_text_repel( force = 0.5, nudge_x = 0.15, direction = \"y\", hjust = 0, segment.size = 0.2 ) + ggtitle(\"hjust = 0\") p2 <- p + xlim(1, 1.375) + geom_text_repel( force = 0.5, nudge_x = 0.2, direction = \"y\", hjust = 0.5, segment.size = 0.2 ) + ggtitle(\"hjust = 0.5 (default)\") p3 <- p + xlim(0.25, 1) + scale_y_continuous(position = \"right\") + geom_text_repel( force = 0.5, nudge_x = -0.25, direction = \"y\", hjust = 1, segment.size = 0.2 ) + ggtitle(\"hjust = 1\") gridExtra::grid.arrange(p1, p2, p3, ncol = 3) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) ggplot(dat, aes(wt, mpg, label = car)) + geom_text_repel( data = subset(dat, wt > 3), nudge_x = 3.5 - subset(dat, wt > 3)$wt, segment.size = 0.2, segment.color = \"grey50\", direction = \"y\", hjust = 0 ) + geom_text_repel( data = subset(dat, wt < 3), nudge_x = 2.7 - subset(dat, wt < 3)$wt, segment.size = 0.2, segment.color = \"grey50\", direction = \"y\", hjust = 1 ) + scale_x_continuous( breaks = c(2.5, 2.75, 3, 3.25, 3.5), limits = c(2.4, 3.8) ) + geom_point(color = \"red\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"using-ggrepel-with-stat_summary","dir":"Articles","previous_headings":"Examples","what":"Using ggrepel with stat_summary()","title":"Examples","text":"can use stat_summary() geom = \"text_repel\". Note: use ggplot2::stat_summary() ggrepel, prefer position_nudge_repel() instead ggplot2::position_nudge(). position_nudge_repel() function nudges text label’s position, also remembers original position data point.","code":"p <- ggplot(mtcars, aes(factor(cyl), mpg)) + stat_summary( fill = \"gray90\", colour = \"black\", fun = \"mean\", geom = \"col\" ) p1 <- p + stat_summary( aes(label = round(stat(y))), fun = \"mean\", geom = \"text_repel\", min.segment.length = 0, # always draw segments position = position_nudge(y = -2) ) + labs(title = \"position_nudge()\") p2 <- p + stat_summary( aes(label = round(stat(y))), fun = \"mean\", geom = \"text_repel\", min.segment.length = 0, # always draw segments position = position_nudge_repel(y = -2) ) + labs(title = \"position_nudge_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"justify-multiple-lines-of-text-with-hjust","dir":"Articles","previous_headings":"Examples","what":"Justify multiple lines of text with hjust","title":"Examples","text":"hjust option behave mostly way ggplot2::geom_text().","code":"p <- ggplot() + coord_cartesian(xlim=c(0,1), ylim=c(0,1)) + theme_void() labelInfo <- data.frame( x = c(0.45, 0.55), y = c(0.5, 0.5), g = c( \"I'd like very much to be\\nright justified.\", \"And I'd like to be\\nleft justified.\" ) ) p + geom_text_repel( data = labelInfo, mapping = aes(x, y, label = g), size = 5, hjust = c(1, 0), nudge_x = c(-0.05, 0.05), arrow = arrow(length = unit(2, \"mm\"), ends = \"last\", type = \"closed\") ) p + geom_label_repel( data = labelInfo, mapping = aes(x, y, label = g), size = 5, hjust = c(1, 0), nudge_x = c(-0.05, 0.05), arrow = arrow(length = unit(2, \"mm\"), ends = \"last\", type = \"closed\") )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"label-jittered-points","dir":"Articles","previous_headings":"Examples","what":"Label jittered points","title":"Examples","text":"can also use position functions, like position_quasirandom() ggbeeswarm package Erik Clarke:","code":"mtcars$label <- rownames(mtcars) mtcars$label[mtcars$cyl != 6] <- \"\" # Available since ggplot2 2.2.1 pos <- position_jitter(width = 0.3, seed = 2) ggplot(mtcars, aes(factor(cyl), mpg, color = label != \"\", label = label)) + geom_point(position = pos) + geom_text_repel(position = pos) + theme(legend.position = \"none\") + labs(title = \"position_jitter()\") mtcars$label <- rownames(mtcars) mtcars$label[mtcars$cyl != 6] <- \"\" library(ggbeeswarm) pos <- position_quasirandom() ggplot(mtcars, aes(factor(cyl), mpg, color = label != \"\", label = label)) + geom_point(position = pos) + geom_text_repel(position = pos) + theme(legend.position = \"none\") + labs(title = \"position_quasirandom()\")"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"label-sf-objects","dir":"Articles","previous_headings":"Examples","what":"Label sf objects","title":"Examples","text":"Currently use geom_text_repel() geom_label_repel() ggplot2::geom_sf plot, probably get error like Error: geom_label_repel requires following missing aesthetics: x y ’s workaround enable ggrepel functions work spatial sf plots like - just need include: stat = \"sf_coordinates\" geom_text|label_repel() call. Thanks Hiroaki Yutani solution.","code":"# thanks to Hiroaki Yutani # https://github.com/slowkow/ggrepel/issues/111#issuecomment-416853013 library(ggplot2) library(sf) nc <- sf::st_read(system.file(\"shape/nc.shp\", package=\"sf\"), quiet = TRUE) ggplot(nc) + geom_sf() + ggrepel::geom_label_repel( data = head(nc), aes(label = NAME, geometry = geometry), stat = \"sf_coordinates\", min.segment.length = 0 )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"shadows-or-glow-under-text-labels","dir":"Articles","previous_headings":"Examples","what":"Shadows (or glow) under text labels","title":"Examples","text":"can place shadows (glow) underneath text label enhance readability text. might useful text labels placed top plot elements. feature uses code shadowtext package Guangchuang Yu.","code":"set.seed(42) ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") + geom_text_repel( color = \"white\", # text color bg.color = \"grey30\", # shadow color bg.r = 0.15 # shadow radius )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"verbose-timing-information","dir":"Articles","previous_headings":"Examples","what":"Verbose timing information","title":"Examples","text":"Use verbose = TRUE see: many iterations physical simulation completed much time elapsed, seconds many overlaps remain unresolved final figure","code":"p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) + geom_point() p + geom_text_repel( verbose = TRUE, seed = 123, max.time = 1, max.iter = Inf, size = 3 ) ## 1.00s elapsed for 147760 iterations, 2 overlaps. Consider increasing 'max.time'."},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"word-cloud","dir":"Articles","previous_headings":"Examples","what":"Word cloud","title":"Examples","text":"Note: ggwordcloud package Erwan Le Pennec creates much better word clouds ggrepel. force option controls strength repulsion. force_pull option controls strength spring pulls text label toward data point. make word cloud, can assign text labels data point origin (0, 0) set force_pull = 0 disable springs.","code":"set.seed(42) ggplot(mtcars) + geom_text_repel( aes( label = rownames(mtcars), size = mpg > 15, colour = factor(cyl), x = 0, y = 0 ), force_pull = 0, # do not pull text toward the point at (0,0) max.time = 0.5, max.iter = 1e5, max.overlaps = Inf, segment.color = NA, point.padding = NA ) + theme_void() + theme(strip.text = element_text(size = 16)) + facet_wrap(~ factor(cyl)) + scale_color_discrete(name = \"Cylinders\") + scale_size_manual(values = c(2, 3)) + theme( strip.text = element_blank(), panel.border = element_rect(size = 0.2, fill = NA) )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"polar-coordinates","dir":"Articles","previous_headings":"Examples","what":"Polar coordinates","title":"Examples","text":"","code":"set.seed(42) mtcars$label <- rownames(mtcars) mtcars$label[mtcars$mpg < 25] <- \"\" ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl), label = label)) + coord_polar(theta = \"x\") + geom_point(size = 2) + scale_color_discrete(name = \"cyl\") + geom_text_repel(show.legend = FALSE) + # Don't display \"a\" in the legend. theme_bw(base_size = 18)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"unicode-characters-japanese","dir":"Articles","previous_headings":"Examples","what":"Unicode characters (Japanese)","title":"Examples","text":"","code":"library(ggrepel) set.seed(42) dat <- data.frame( x = runif(32), y = runif(32), label = strsplit( x = \"原文篭毛與美篭母乳布久思毛與美夫君志持此岳尓菜採須兒家吉閑名思毛\", split = \"\" )[[1]] ) # Make sure to choose a font that is installed on your system. my_font <- \"HiraginoSans-W0\" ggplot(dat, aes(x, y, label = label)) + geom_point(size = 2, color = \"red\") + geom_text_repel(size = 8, family = my_font) + ggtitle(\"テスト\") + theme_bw(base_size = 18, base_family = my_font)"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"mathematical-expressions","dir":"Articles","previous_headings":"Examples","what":"Mathematical expressions","title":"Examples","text":"","code":"d <- data.frame( x = c(1, 2, 2, 1.75, 1.25), y = c(1, 3, 1, 2.65, 1.25), math = c( NA, \"integral(f(x) * dx, a, b)\", NA, \"lim(f(x), x %->% 0)\", NA ) ) ggplot(d, aes(x, y, label = math)) + geom_point() + geom_label_repel( parse = TRUE, # Parse mathematical expressions. size = 6, box.padding = 2 )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"animation","dir":"Articles","previous_headings":"Examples","what":"Animation","title":"Examples","text":"","code":"# This chunk of code will take a minute or two to run. library(ggrepel) library(animation) plot_frame <- function(n) { set.seed(42) p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) + geom_text_repel( size = 5, force = 1, max.iter = n ) + geom_point(color = \"red\") + # theme_minimal(base_size = 16) + labs(title = n) print(p) } xs <- ceiling(1.18^(1:52)) # xs <- ceiling(1.4^(1:26)) xs <- c(xs, rep(xs[length(xs)], 15)) # plot(xs) saveGIF( lapply(xs, function(i) { plot_frame(i) }), interval = 0.15, ani.width = 800, ani.heigth = 600, movie.name = \"animated.gif\" )"},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"source-code","dir":"Articles","previous_headings":"","what":"Source code","title":"Examples","text":"View source code vignette GitHub.","code":""},{"path":"https://ggrepel.slowkow.com/articles/examples.html","id":"r-session-info","dir":"Articles","previous_headings":"","what":"R Session Info","title":"Examples","text":"","code":"sessionInfo() ## R version 4.2.3 (2023-03-15) ## Platform: aarch64-apple-darwin20 (64-bit) ## Running under: macOS Ventura 13.4 ## ## Matrix products: default ## BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib ## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib ## ## locale: ## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 ## ## attached base packages: ## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: ## [1] pkgdown_2.0.7 glue_1.6.2 rvest_1.0.3 sf_1.0-12 ## [5] ggbeeswarm_0.7.2 ggrepel_0.9.5 ggplot2_3.4.4 gridExtra_2.3 ## [9] knitr_1.43 ## ## loaded via a namespace (and not attached): ## [1] beeswarm_0.4.0 tidyselect_1.2.0 xfun_0.39 bslib_0.5.0 ## [5] purrr_1.0.1 colorspace_2.1-0 vctrs_0.6.5 generics_0.1.3 ## [9] htmltools_0.5.5 yaml_2.3.7 utf8_1.2.4 rlang_1.1.2 ## [13] e1071_1.7-13 jquerylib_0.1.4 pillar_1.9.0 withr_2.5.2 ## [17] DBI_1.1.3 lifecycle_1.0.4 stringr_1.5.0 munsell_0.5.0 ## [21] gtable_0.3.4 ragg_1.2.5 codetools_0.2-19 memoise_2.0.1 ## [25] evaluate_0.21 labeling_0.4.3 fastmap_1.1.1 vipor_0.4.5 ## [29] class_7.3-21 fansi_1.0.5 highr_0.10 Rcpp_1.0.11 ## [33] KernSmooth_2.23-20 scales_1.3.0 classInt_0.4-9 cachem_1.0.8 ## [37] desc_1.4.2 jsonlite_1.8.7 farver_2.1.1 systemfonts_1.0.4 ## [41] fs_1.6.2 textshaping_0.3.6 digest_0.6.31 stringi_1.7.12 ## [45] dplyr_1.1.2 grid_4.2.3 rprojroot_2.0.3 cli_3.6.1 ## [49] tools_4.2.3 magrittr_2.0.3 sass_0.4.6 proxy_0.4-27 ## [53] tibble_3.2.1 pkgconfig_2.0.3 xml2_1.3.4 httr_1.4.6 ## [57] rmarkdown_2.23 R6_2.5.1 units_0.8-2 compiler_4.2.3"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Getting started with ggrepel","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area (panel). Let’s compare geom_text() geom_text_repel():","code":"library(ggrepel) set.seed(42) dat <- subset(mtcars, wt > 2.75 & wt < 3.45) dat$car <- rownames(dat) p <- ggplot(dat, aes(wt, mpg, label = car)) + geom_point(color = \"red\") p1 <- p + geom_text() + labs(title = \"geom_text()\") p2 <- p + geom_text_repel() + labs(title = \"geom_text_repel()\") gridExtra::grid.arrange(p1, p2, ncol = 2)"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Getting started with ggrepel","text":"ggrepel available CRAN: latest development version may new features, can get GitHub:","code":"install.packages(\"ggrepel\") # Use the devtools package # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/articles/ggrepel.html","id":"usage","dir":"Articles","previous_headings":"","what":"Usage","title":"Getting started with ggrepel","text":"See examples page learn use ggrepel project.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ggforce","dir":"Articles","previous_headings":"R","what":"ggforce","title":"Related work","text":"Annotation important storytelling, ggforce provides family geoms makes easy draw attention , describe, features plot. work way, differ way enclose area want draw attention .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"directlabels","dir":"Articles","previous_headings":"R","what":"directlabels","title":"Related work","text":"extensible framework automatically placing direct labels onto multicolor ‘lattice’ ‘ggplot2’ plots. Label positions described using Positioning Methods can re-used across several different plots. heuristics examining “trellis” “ggplot” objects inferring appropriate Positioning Method.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ggwordcloud","dir":"Articles","previous_headings":"R","what":"ggwordcloud","title":"Related work","text":"ggwordcloud provides word cloud text geom ggplot2. placement algorithm implemented C++ hybrid one wordcloud one wordcloud2.js. cloud can grow according shape stay within mask. size aesthetic used either control font size printed area words. ggwordcloud also supports arbitrary text rotation. faceting scheme ggplot2 can also used. ggwordcloud package implements spiraling algorithm prevent text labels overlapping .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"wordcloud","dir":"Articles","previous_headings":"R","what":"wordcloud","title":"Related work","text":"Pretty word clouds. wordcloud package implements spiraling algorithm prevent text labels overlapping .","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"ffield","dir":"Articles","previous_headings":"R","what":"FField","title":"Related work","text":"Force field simulation interaction set points. useful placing text labels graphs, scatterplots. found functions FField package ideal repelling overlapping rectangles, wrote . See gist examples use wordcloud FField packages ggplot2.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"vega-label","dir":"Articles","previous_headings":"Javascript","what":"vega-label","title":"Related work","text":"Fast Flexible Overlap Detection Chart Labeling Occupancy Bitmaps Chanwut Kittivorawang, Dominik Moritz, Kanit Wongsuphasawat, Jeffrey Heer http://idl.cs.washington.edu/papers/fast-labels/","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3-labeler","dir":"Articles","previous_headings":"Javascript","what":"D3-Labeler","title":"Related work","text":"D3 plug-automatic label placement using simulated annealing Evan Wang’s plugin extends D3 v3. also described approach paper.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3fc-label-layout","dir":"Articles","previous_headings":"Javascript","what":"d3fc-label-layout","title":"Related work","text":"D3 layout places labels avoiding overlaps, strategies including simulated annealing, greedy strategy removes overlapping labels. Colin Eberhardt’s implementation D3 v4.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"d3-voronoi-labels","dir":"Articles","previous_headings":"Javascript","what":"d3-voronoi-labels","title":"Related work","text":"Voronoi tessellation can assist labeling scatterplots. area Voronoi cell associated point determines whether point labeled: points larger cells tend room accommodate labels.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"adjusttext","dir":"Articles","previous_headings":"Python","what":"adjustText","title":"Related work","text":"small library automatically adjusting text position matplotlib plots minimize overlaps. Ilya Flyamer’s Python library extends matplotlib.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"an-efficient-algorithm-for-scatter-chart-labelingaaai","dir":"Articles","previous_headings":"Academic Papers","what":"An Efficient Algorithm for Scatter Chart Labeling","title":"Related work","text":"Sebastian Theophil, Arno Schödl paper presents efficient algorithm new variation point feature labeling problem. goal position largest number point labels intersect points. First present algorithm using greedy algorithm limited lookahead. present algorithm iteratively regroups labels, calling first algorithm group, thereby identifying close optimal labeling order. presented algorithm used commercial product label charts, evaluation shows produces results far superior labeling algorithms. might good start revision ggrepel.","code":""},{"path":"https://ggrepel.slowkow.com/articles/related-work.html","id":"chapter-15--labeling-algorithmsbrown","dir":"Articles","previous_headings":"Academic Papers","what":"Chapter 15. Labeling Algorithms","title":"Related work","text":"Konstantinos G. Kakoulis, Ioannis G. Tollis important aspect information visualization automatic placement text symbol labels corresponding graphical features drawings maps. Labels textual descriptions convey information clarify meaning complex structures presented graphical form. automatic label placement problem identified important research area ACM Computational Geometry Task Force [C +99]. applications many areas including cartography [RMM+95], geographic information systems [Fre91], graph drawing [DETT99]. Handbook Graph Drawing Visualization, Roberto Tamassia (Editor), CRC Press, June 24, 2013.","code":""},{"path":"https://ggrepel.slowkow.com/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Kamil Slowikowski. Author, maintainer. Alicia Schep. Contributor. Sean Hughes. Contributor. Trung Kien Dang. Contributor. Saulius Lukauskas. Contributor. Jean-Olivier Irisson. Contributor. Zhian N Kamvar. Contributor. Thompson Ryan. Contributor. Dervieux Christophe. Contributor. Yutani Hiroaki. Contributor. Pierre Gramme. Contributor. Amir Masoud Abdol. Contributor. Malcolm Barrett. Contributor. Robrecht Cannoodt. Contributor. Michał Krassowski. Contributor. Michael Chirico. Contributor. Pedro Aphalo. Contributor. Francis Barton. Contributor.","code":""},{"path":"https://ggrepel.slowkow.com/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Slowikowski K (2024). ggrepel: Automatically Position Non-Overlapping Text Labels 'ggplot2'. https://ggrepel.slowkow.com/, https://github.com/slowkow/ggrepel.","code":"@Manual{, title = {ggrepel: Automatically Position Non-Overlapping Text Labels with 'ggplot2'}, author = {Kamil Slowikowski}, year = {2024}, note = {https://ggrepel.slowkow.com/, https://github.com/slowkow/ggrepel}, }"},{"path":"https://ggrepel.slowkow.com/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"ggrepel: An R package","text":"ggrepel provides geoms ggplot2 repel overlapping text labels: geom_text_repel() geom_label_repel() Text labels repel away , away data points, away edges plotting area.","code":"library(ggrepel) ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) + geom_text_repel() + geom_point(color = 'red') + theme_classic(base_size = 16)"},{"path":"https://ggrepel.slowkow.com/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"ggrepel: An R package","text":"","code":"# The easiest way to get ggrepel is to install it from CRAN: install.packages(\"ggrepel\") # Or get the latest development version from GitHub: # install.packages(\"devtools\") devtools::install_github(\"slowkow/ggrepel\")"},{"path":"https://ggrepel.slowkow.com/index.html","id":"getting-help","dir":"","previous_headings":"","what":"Getting help","title":"ggrepel: An R package","text":"Check examples learn use ggrepel project. See collection related work similar R packages, Python packages, . issue ggrepel ggplot2, someone might already experienced . Try searching web, create new post: RStudio community active forum RStudio R users. Stack Overflow lots questions answers ggplot2 ggrepel.","code":""},{"path":"https://ggrepel.slowkow.com/index.html","id":"examples","dir":"","previous_headings":"","what":"Examples","title":"ggrepel: An R package","text":"Click one 22 images view source code figure:","code":""},{"path":"https://ggrepel.slowkow.com/index.html","id":"thanks","dir":"","previous_headings":"","what":"Thanks","title":"ggrepel: An R package","text":"Thanks everyone contributed pull requests, opened issues, asked questions, shared examples! thanks Allison Horst beautiful artwork!","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":null,"dir":"Reference","previous_headings":"","what":"Repulsive textual annotations. — geom_label_repel","title":"Repulsive textual annotations. — geom_label_repel","text":"geom_text_repel adds text directly plot. geom_label_repel draws rectangle underneath text, making easier read. text labels repel away away data points.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Repulsive textual annotations. — geom_label_repel","text":"","code":"geom_label_repel( mapping = NULL, data = NULL, stat = \"identity\", position = \"identity\", parse = FALSE, ..., box.padding = 0.25, label.padding = 0.25, point.padding = 1e-06, label.r = 0.15, label.size = 0.25, min.segment.length = 0.5, arrow = NULL, force = 1, force_pull = 1, max.time = 0.5, max.iter = 10000, max.overlaps = getOption(\"ggrepel.max.overlaps\", default = 10), nudge_x = 0, nudge_y = 0, xlim = c(NA, NA), ylim = c(NA, NA), na.rm = FALSE, show.legend = NA, direction = c(\"both\", \"y\", \"x\"), seed = NA, verbose = FALSE, inherit.aes = TRUE ) geom_text_repel( mapping = NULL, data = NULL, stat = \"identity\", position = \"identity\", parse = FALSE, ..., box.padding = 0.25, point.padding = 1e-06, min.segment.length = 0.5, arrow = NULL, force = 1, force_pull = 1, max.time = 0.5, max.iter = 10000, max.overlaps = getOption(\"ggrepel.max.overlaps\", default = 10), nudge_x = 0, nudge_y = 0, xlim = c(NA, NA), ylim = c(NA, NA), na.rm = FALSE, show.legend = NA, direction = c(\"both\", \"y\", \"x\"), seed = NA, verbose = FALSE, inherit.aes = TRUE )"},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Repulsive textual annotations. — geom_label_repel","text":"mapping Set aesthetic mappings created aes aes_. specified inherit.aes = TRUE (default), combined default mapping top level plot. need supply mapping mapping defined plot. data data frame. specified, overrides default data frame defined top level plot. stat statistical transformation use data layer, string. position Position adjustment, either string, result call position adjustment function. parse TRUE, labels parsed expressions displayed described ?plotmath ... arguments passed layer. three types arguments can use : Aesthetics: set aesthetic fixed value, like colour = \"red\" size = 3. arguments layer, example override default stat associated layer. arguments passed stat. box.padding Amount padding around bounding box, unit number. Defaults 0.25. (Default unit lines, units can specified passing unit(x, \"units\")). label.padding Amount padding around label, unit number. Defaults 0.25. (Default unit lines, units can specified passing unit(x, \"units\")). point.padding Amount padding around labeled point, unit number. Defaults 0. (Default unit lines, units can specified passing unit(x, \"units\")). label.r Radius rounded corners, unit number. Defaults 0.15. (Default unit lines, units can specified passing unit(x, \"units\")). label.size Size label border, mm. min.segment.length Skip drawing segments shorter , unit number. Defaults 0.5. (Default unit lines, units can specified passing unit(x, \"units\")). arrow specification arrow heads, created arrow force Force repulsion overlapping text labels. Defaults 1. force_pull Force attraction text label corresponding data point. Defaults 1. max.time Maximum number seconds try resolve overlaps. Defaults 0.5. max.iter Maximum number iterations try resolve overlaps. Defaults 10000. max.overlaps Exclude text labels overlap many things. text label, count many text labels data points overlaps, exclude text label many overlaps. Defaults 10. nudge_x, nudge_y Horizontal vertical adjustments nudge starting position text label. units nudge_x nudge_y data units x-axis y-axis. xlim, ylim Limits x y axes. Text labels constrained limits. default, text labels constrained entire plot area. na.rm FALSE (default), removes missing values warning. TRUE silently removes missing values. show.legend logical. layer included legends? NA, default, includes aesthetics mapped. FALSE never includes, TRUE always includes. direction \"\", \"x\", \"y\" -- direction adjust position labels seed Random seed passed set.seed. Defaults NA, means set.seed called. verbose TRUE, diagnostics repel algorithm printed inherit.aes FALSE, overrides default aesthetics, rather combining . useful helper functions define data aesthetics inherit behaviour default plot specification, e.g. borders.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Repulsive textual annotations. — geom_label_repel","text":"geoms based geom_text geom_label. See documentation functions details. Differences functions noted . Text labels height width, physical units, data units. amount space occupy plot constant data units: resize plot, labels stay size, size axes changes. text labels repositioned resizing plot.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"geom-label-repel","dir":"Reference","previous_headings":"","what":"geom_label_repel","title":"Repulsive textual annotations. — geom_label_repel","text":"Currently geom_label_repel support rot argument considerably slower geom_text_repel. fill aesthetic controls background colour label.","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"alignment-with-hjust-or-vjust","dir":"Reference","previous_headings":"","what":"Alignment with hjust or vjust","title":"Repulsive textual annotations. — geom_label_repel","text":"arguments hjust vjust supported, control initial positioning, repulsive forces may disrupt alignment. Alignment hjust preserved labels move using direction=\"y\". vjust, use direction=\"x\".","code":""},{"path":"https://ggrepel.slowkow.com/reference/geom_text_repel.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Repulsive textual annotations. — geom_label_repel","text":"","code":"p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars), colour = factor(cyl))) + geom_point() # Avoid overlaps by repelling text labels p + geom_text_repel() # Labels with background p + geom_label_repel() #> Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider increasing max.overlaps if (FALSE) { p + geom_text_repel(family = \"Times New Roman\", box.padding = 0.5) # Add aesthetic mappings p + geom_text_repel(aes(alpha=wt, size=mpg)) p + geom_label_repel(aes(fill=factor(cyl)), colour=\"white\", segment.colour=\"black\") # Draw all line segments p + geom_text_repel(min.segment.length = 0) # Omit short line segments (default behavior) p + geom_text_repel(min.segment.length = 0.5) # Omit all line segments p + geom_text_repel(segment.colour = NA) # Repel just the labels and totally ignore the data points p + geom_text_repel(point.size = NA) # Hide some of the labels, but repel from all data points mtcars$label <- rownames(mtcars) mtcars$label[1:15] <- \"\" p + geom_text_repel(data = mtcars, aes(wt, mpg, label = label)) # Nudge the starting positions p + geom_text_repel(nudge_x = ifelse(mtcars$cyl == 6, 1, 0), nudge_y = ifelse(mtcars$cyl == 6, 8, 0)) # Change the text size p + geom_text_repel(aes(size = wt)) # Scale height of text, rather than sqrt(height) p + geom_text_repel(aes(size = wt)) + scale_radius(range = c(3,6)) # You can display expressions by setting parse = TRUE. The # details of the display are described in ?plotmath, but note that # geom_text_repel uses strings, not expressions. p + geom_text_repel(aes(label = paste(wt, \"^(\", cyl, \")\", sep = \"\")), parse = TRUE) # Add a text annotation p + geom_text_repel() + annotate( \"text\", label = \"plot mpg vs. wt\", x = 2, y = 15, size = 8, colour = \"red\" ) # Add arrows p + geom_point(colour = \"red\") + geom_text_repel( arrow = arrow(length = unit(0.02, \"npc\")), box.padding = 1 ) }"},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":null,"dir":"Reference","previous_headings":"","what":"GeomLabelRepel — GeomLabelRepel","title":"GeomLabelRepel — GeomLabelRepel","text":"package contains extra geoms ggplot2.","code":""},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"GeomLabelRepel — GeomLabelRepel","text":"Please see help pages listed : geom_text_repel geom_label_repel Also see vignette usage examples: browseVignettes(\"ggrepel\") Please report issues suggest improvements Github: https://github.com/slowkow/ggrepel","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/reference/ggrepel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"GeomLabelRepel — GeomLabelRepel","text":"Maintainer: Kamil Slowikowski kslowikowski@gmail.com (ORCID) contributors: Alicia Schep (ORCID) [contributor] Sean Hughes (ORCID) [contributor] Trung Kien Dang (ORCID) [contributor] Saulius Lukauskas [contributor] Jean-Olivier Irisson (ORCID) [contributor] Zhian N Kamvar (ORCID) [contributor] Thompson Ryan (ORCID) [contributor] Dervieux Christophe (ORCID) [contributor] Yutani Hiroaki [contributor] Pierre Gramme [contributor] Amir Masoud Abdol [contributor] Malcolm Barrett (ORCID) [contributor] Robrecht Cannoodt (ORCID) [contributor] Michał Krassowski (ORCID) [contributor] Michael Chirico (ORCID) [contributor] Pedro Aphalo (ORCID) [contributor] Francis Barton [contributor]","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":null,"dir":"Reference","previous_headings":"","what":"Nudge labels a fixed distance from points — position_nudge_repel","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"position_nudge_repel useful adjusting starting position text labels repelled data points.","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"","code":"position_nudge_repel(x = 0, y = 0)"},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"x, y Amount horizontal vertical distance move. units data x y axes.","code":""},{"path":"https://ggrepel.slowkow.com/reference/position_nudge_repel.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Nudge labels a fixed distance from points — position_nudge_repel","text":"","code":"df <- data.frame( x = c(1,3,2,5), y = c(\"a\",\"c\",\"d\",\"c\") ) ggplot(df, aes(x, y)) + geom_point() + geom_text_repel(aes(label = y)) ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, position = position_nudge_repel(x = 0.1, y = 0.15) ) # The values for x and y can be vectors ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, position = position_nudge_repel( x = c(0.1, 0, -0.1, 0), y = c(0.1, 0.2, -0.1, -0.2) ) ) # We can also use geom_text_repel() with arguments nudge_x, nudge_y ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, nudge_x = 0.1, nudge_y = 0.15 ) # The arguments nudge_x, nudge_y also accept vectors ggplot(df, aes(x, y)) + geom_point() + geom_text_repel( aes(label = y), min.segment.length = 0, nudge_x = c(0.1, 0, -0.1, 0), nudge_y = c(0.1, 0.2, -0.1, -0.2) )"},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.5","text":"Change expect_equal() include tolerance, satisfy CRAN testing. Delete note old (2.2.1) versions ggplot2, thanks @olivroy pull request 246. Add website link DESCRIPTION, thanks @olivroy pull request 241.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-094","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.4","title":"ggrepel 0.9.4","text":"CRAN release: 2023-10-12","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.4","text":"Add min.segment.length options table examples page, thanks @jwhendy mentioning . Add example use ggrepel sf objects, .e. geom_text_repel(..., stat = \"sf_coordinates\"), thanks @francisbarton pull request 236. Use expect_equal(x, y) instead expect_true(identical(x, y)), see issue 242 details.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-093","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.3","title":"ggrepel 0.9.3","text":"CRAN release: 2023-02-03","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-3","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.3","text":"set seed ggrepel::geom_text_repel(seed = 1), longer override seed unrelated code. Thanks @kassambara reporting issue 228.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-092","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.2","title":"ggrepel 0.9.2","text":"CRAN release: 2022-11-06","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-2","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.2","text":"Fix compiler errors C++ expressions like v[] = {0,0} arise versions clang compiler. Thanks @Krascal @vrognas reporting issue 184. Fix warning CRAN warning: use bitwise '&' boolean operands","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.2","text":"Change internal column names, ggrepel::position_nudge_repel() can now used ggplot2::geom_text(). also allow us use new nudge functions ggpp package @aphalo. Thanks @aphalo pull request 193. Improve handling justification angle different zero ggrepel::geom_text_repel() pull request 196.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-091-2021-01-09","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.1 2021-01-09","title":"ggrepel 0.9.1 2021-01-09","text":"CRAN release: 2021-01-15","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-9-1","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.9.1 2021-01-09","text":"Fix label positions (geom_label_repel()). plot look OK ggrepel 0.8.2, incorrect ggrepel 0.9.0. Thanks Ben Baumer (@beanumber) reporting issue 182. Fix bug caused R crash (Windows, Linux macOS) specific code examples. Thanks Pedro Aphalo (@aphalo) reporting issue 179 testing patched code.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-090-2020-12-14","dir":"Changelog","previous_headings":"","what":"ggrepel 0.9.0 2020-12-14","title":"ggrepel 0.9.0 2020-12-14","text":"CRAN release: 2020-12-16","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-9-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.9.0 2020-12-14","text":"Points can different sizes. Repel text labels large points small points. New examples vignette show . See discussion feature issue 83. New parameter max.overlaps stops ggrepel trying label overcrowded data points. default setting max.overlaps = 10, text labels overlap 10 things (points labels) excluded calculations rendering. course, can set max.overlaps = Inf restore behavior ggrepel 0.8.1. See [issue 48] discussion. can also use option(ggrepel.max.overlaps = Inf) disable new functionality display labels, regardless many overlaps. Add examples vignette ggplot2::position_jitter() ggbeeswarm::position_quasirandom() Line segments can now curved (#131, @malcolmbarrett). Add examples vignette showing different options. Add support new aesthetics: segment.size segment.colour segment.alpha segment.curvature segment.angle segment.ncp Add max.time option limit number seconds spent trying position text labels. Add verbose option show timing information: seconds elapse, iteration count, number remaining overlaps (thanks @MichaelChirico #159). Add bg.color bg.r aesthetics geom_text() display shadows behind text labels. Thanks @rcannood adding feature pull request 142.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-9-0","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.9.0 2020-12-14","text":"Line segments color text default (#164, @lishinkou). Text justification multi-line text labels working expected. Thanks @johnhenrypezzuto @phalteman comments issue 137. Put text labels top line segments (@kiendang). fixes issue 35, line segments sometimes appear top text. Thanks Paul Murrell (@pmur002) notifying us use .unit(x) instead class(x) == \"unit\" issue 141. future-proof ggrepel new versions grid package. Fix way xlim = c(-Inf, Inf) treated. Thanks @thomasp85 pointing bug issue 136. segment.shape segment.square segment.squareShape segment.inflect","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-081-2019-05-07","dir":"Changelog","previous_headings":"","what":"ggrepel 0.8.1 2019-05-07","title":"ggrepel 0.8.1 2019-05-07","text":"CRAN release: 2019-05-07","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-8-1","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.8.1 2019-05-07","text":"Fix heap buffer overflow causes R crash. See issue 115. Thanks Brodie Gaslam (@brodieG) helping setup environment reproduce bug system.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-080-2018-05-09","dir":"Changelog","previous_headings":"","what":"ggrepel 0.8.0 2018-05-09","title":"ggrepel 0.8.0 2018-05-09","text":"CRAN release: 2018-05-09","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-8-0","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.8.0 2018-05-09","text":"Fix geom_label_repel(..., point.padding=NA). Reported @mlell issue 104.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-7-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.7.3 2018-02-09","text":"Add support position parameter. See issue 69. allows us add text labels points positioned position_jitter(), position_dodge(), position_jitterdodge(), etc. Please note feature work ggplot2 2.2.1 older.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-and-improvements-0-7-2","dir":"Changelog","previous_headings":"","what":"Bug fixes and improvements","title":"ggrepel 0.7.2 2018-01-14","text":"Thanks @AliciaSchep @aphalo Fix warning hjust. See issue 93. Fix bug subset points labeled geom_label_repel. See issue 92.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-7-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.7.1 2017-11-18","text":"Thanks @AliciaSchep Add support hjust vjust parameters. See issue 69. Also see new examples vignette. Add code avoid intersecting line segments. See issue 34.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-070-2017-09-28","dir":"Changelog","previous_headings":"","what":"ggrepel 0.7.0 2017-09-28","title":"ggrepel 0.7.0 2017-09-28","text":"CRAN release: 2017-09-29","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-7-0","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.7.0 2017-09-28","text":"Fix intersection lines rectangles, reproduce aesthetically pleasant behavior version 0.6.5. improvement sloppy implementation introduced 0.6.8. See commit 28633d information.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-12","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.12 2017-07-16","text":"Reproduce identical plots using seed = 1 set seed geom_text_repel() geom_label_repel(). default, seed set. improvement sloppy implementation introduced 0.6.2. See issue 33 issue 73 discussion feature. Thanks Pierre Gramme reminding via email.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-11","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.11 2017-07-08","text":"Thanks @seaaan Allow certain parameters passed numbers unit() instead units. See issue 79.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-10","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.10 2017-03-07","text":"Thanks @zkamvar Fix crash plots specify xlim ylim. See pull 74.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-9","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.9 2017-03-07","text":"Fix crash plots facet_wrap facet_grid labeled points. Thanks @pcroteau pull 70.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-8","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.8 2017-02-12","text":"Constrain repulsion force x-axis “x” y-axis “y” direction geom_text_repel() geom_label_repel(). Thanks @AliciaSchep pull 68.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-7","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.7 2017-01-09","text":"Constrain text labels specific areas plot xlim ylim geom_text_repel() geom_label_repel(). Thanks @lukauskas pull 67.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-6","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.6 2016-11-28","text":"Mathematical expressions labels parse = TRUE geom_text_repel() geom_label_repel(). Thanks @fawda123 issue 60.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-065-2016-11-22","dir":"Changelog","previous_headings":"","what":"ggrepel 0.6.5 2016-11-22","title":"ggrepel 0.6.5 2016-11-22","text":"CRAN release: 2016-11-24","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.5 2016-11-22","text":"Thanks @jiho : changed alpha geom_label_repel() control text, label background, label border, segment. Allow segment.colour well segment.color. default, map text color text alpha segment color unless overridden. Call scales::alpha() instead alpha().","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.4 2016-11-08","text":"Fix bug caused ggrepel fail polar coordinates coord_polar(). See issue 56.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-063-2016-10-14","dir":"Changelog","previous_headings":"","what":"ggrepel 0.6.3 2016-10-14","title":"ggrepel 0.6.3 2016-10-14","text":"CRAN release: 2016-10-20","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.3 2016-10-14","text":"Use point.padding=NA ignore data points repulsion calculations.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-6-2","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.6.2 2016-10-06","text":"Stop labels escaping plot boundaries instead applying force boundary. Call set.seed within geom_text_repel() geom_label_repel() allow recreating identical plots. Thanks @erikor issue 33.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.2 2016-10-06","text":"Add min.segment.length geom_text_repel() geom_label_repel().","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.1 2016-10-04","text":"Tweak repel_boxes.cpp. Dampen forces tune labels move. result looks better, least examples vignette.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-6-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.6.0 2016-10-03","text":"draw labels empty strings. label empty string, text shown, segment drawn, corresponding data point repel labels. See issue 51. Add segment.alpha option geom_text_repel() geom_label_repel(). Implement angle aesthetic geom_text_repel(), way done ggplot2 geom_text(). Move nudge_x nudge_y aesthetics function aes(). makes ggrepel consistent ggplot2 functions geom_text() geom_label(). Backwards incompatible 0.5.1. Restore segment.color option geom_text_repel() geom_label_repel(). Tweak repel_boxes.cpp. weight repulsion force ratios bounding box heights widths. seems perform better, especially rotating text labels.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-051-2016-02-22","dir":"Changelog","previous_headings":"","what":"ggrepel 0.5.1 2016-02-22","title":"ggrepel 0.5.1 2016-02-22","text":"Optimize C++ code reducing number calls rnorm().","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-05-2016-02-08","dir":"Changelog","previous_headings":"","what":"ggrepel 0.5 2016-02-08","title":"ggrepel 0.5 2016-02-08","text":"CRAN release: 2016-02-08 First push CRAN.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-6","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.6 2016-02-07","text":"Tweak point.padding users can configure far labels pushed away data points.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-5","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.5 2016-02-06","text":"Optimize C++ code 2.5X speed improvment. Delete unnecessary .Rd files.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-044-2016-02-05","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4.4 2016-02-05","title":"ggrepel 0.4.4 2016-02-05","text":"FIXES Fix bug line segment data point points origin (0,0) instead text label.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.4 2016-02-05","text":"Automatically recompute repulsion labels resizing plot.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.3 2016-01-18","text":"Change distance segment label geom_label_repel(). Now gap end segment label border.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-042-2016-01-15","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4.2 2016-01-15","title":"ggrepel 0.4.2 2016-01-15","text":"FIXES Fix spring_force() never returns NaN.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-2","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.2 2016-01-15","text":"Add nudge_x nudge_y better control positioning labels.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4-1","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4.1 2016-01-13","text":"Add arrow parameter allow plotting arrows point labeled data points rather plain line segments. Always draw segments, even labeled point close label. FIXES Fix point.padding horizontal vertical padding calculated correctly. Tweak forces improve layout near borders crowded areas.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-04-2016-01-12","dir":"Changelog","previous_headings":"","what":"ggrepel 0.4 2016-01-12","title":"ggrepel 0.4 2016-01-12","text":"CRAN release: 2016-01-12","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"bug-fixes-0-4","dir":"Changelog","previous_headings":"","what":"Bug fixes","title":"ggrepel 0.4 2016-01-12","text":"Fix issue 7. Labels can now placed anywhere plotting area instead limited x y ranges corresponding data points. Fix DESCRIPTION require ggplot2 >= 2.0.0","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-4","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.4 2016-01-12","text":"Add new parameter point.padding add padding around labeled points. line segment stop reaching coordinates point. text labels also now padded line segment improve legibility. Add volcano plot vignette usage examples. Add Travis continuous integration test R-devel, R-release, R-oldrel. Dampen repulsion force slightly improve algorithm efficiency. Move intersect_line_rectangle() src/repel_boxes.cpp.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-03-2016-01-08","dir":"Changelog","previous_headings":"","what":"ggrepel 0.3 2016-01-08","title":"ggrepel 0.3 2016-01-08","text":"CRAN release: 2016-01-09","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-3","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.3 2016-01-08","text":"Remove unused imports: colorspace. Update NAMESPACE new version roxygen. Use spring force attract label point. Change default maximum iterations 10,000 2000. Update man pages. Remove unused code.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-2-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.2.0 2016-01-07","text":"Update geom_text_repel() geom_label_repel(). Change label.padding box.padding. Remove unsupported parameters: position nudge_x nudge_y hjust vjust Remove unused imports.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"documentation-0-2-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"ggrepel 0.2.0 2016-01-07","text":"Add roxygen docs functions.","code":""},{"path":[]},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"changes-0-1-0","dir":"Changelog","previous_headings":"","what":"Changes","title":"ggrepel 0.1.0 2016-01-05","text":"Add geom_label_repel(). Add fudge width help legends. Add expand=TRUE allow text placed expanded plot area. Add man/ folder. Add links ggplot2 docs vignette. Add unused R implementation repel_boxes(), just reference.","code":""},{"path":"https://ggrepel.slowkow.com/news/index.html","id":"ggrepel-001-2016-01-04","dir":"Changelog","previous_headings":"","what":"ggrepel 0.0.1 2016-01-04","title":"ggrepel 0.0.1 2016-01-04","text":"Initial release github.","code":""}]
diff --git a/man/geom_text_repel.Rd b/man/geom_text_repel.Rd
index f292f5b..d6049a8 100644
--- a/man/geom_text_repel.Rd
+++ b/man/geom_text_repel.Rd
@@ -131,7 +131,8 @@ Defaults to 0.5.}
Defaults to 10000.}
\item{max.overlaps}{Exclude text labels when they overlap too many other
-things (other text labels or other data points).
+things. For each text label, we count how many other text labels or other
+data points it overlaps, and exclude the text label if it has too many overlaps.
Defaults to 10.}
\item{nudge_x, nudge_y}{Horizontal and vertical adjustments to nudge the