Skip to content

Instantly share code, notes, and snippets.

@EmilHvitfeldt
Created February 25, 2018 06:35
Show Gist options
  • Save EmilHvitfeldt/acb849a6135a21426c260850cf0f461b to your computer and use it in GitHub Desktop.
Save EmilHvitfeldt/acb849a6135a21426c260850cf0f461b to your computer and use it in GitHub Desktop.
Horizontal annotations with ggrepel and ggplot2
library(tidyverse)
library(ggrepel)
set.seed(1234)
data <- tibble(x = seq_len(100),
y = cumsum(rnorm(100)))
anno_data <- data %>%
filter(x %% 25 == 10) %>%
mutate(text = "text")
data %>%
ggplot(aes(x, y)) +
geom_line() +
geom_label_repel(aes(label = text),
data = anno_data,
direction = "y",
nudge_y = c(-5, 5, 5, 5))
@shenwei356
Copy link

library(dplyr) missing

@EmilHvitfeldt
Copy link
Author

@shenwei356 dplyr is being loaded as a part of library(tidyverse).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment