Skip to contents

Drop-in replacements for geom_text_repel and geom_label_repel with sensible defaults from ggastrum: labels that overlap are automatically hidden rather than overlapping, segment colors and sizes match the solaris theme, and a fixed random seed ensures reproducible layouts across renders.

Usage

geom_qlabel(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  parse = FALSE,
  ...,
  max.overlaps = .QUIET_MAX_OVERLAPS,
  min.segment.length = .QUIET_MIN_SEGMENT,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

geom_qlabel_box(
  mapping = NULL,
  data = NULL,
  stat = "identity",
  position = "identity",
  parse = FALSE,
  ...,
  max.overlaps = .QUIET_MAX_OVERLAPS,
  min.segment.length = .QUIET_MIN_SEGMENT,
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE
)

Arguments

mapping, data, stat, position, ...

Same as geom_text_repel / geom_label_repel.

parse

Logical. If TRUE, labels are parsed as expressions.

max.overlaps

Integer. Labels that would overlap more than this many other labels are removed. Default 8.

min.segment.length

Numeric. Segment shorter than this are hidden (default 0.25).

na.rm

Logical. If TRUE, missing values are silently removed.

show.legend

Logical. Whether to include this layer in the legend.

inherit.aes

Logical. Whether to inherit aesthetics from the plot.

Value

A ggplot2 layer object.

Details

These geoms pass all arguments through to their ggrepel counterparts. The only difference is the default parameter values set by set_theme.

Examples

if (FALSE) { # \dontrun{
library(ggplot2)
ggastrum::set_theme()

ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
  geom_point() +
  geom_qlabel()

ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
  geom_point() +
  geom_qlabel_box()
} # }