Created
February 25, 2018 06:35
-
-
Save EmilHvitfeldt/acb849a6135a21426c260850cf0f461b to your computer and use it in GitHub Desktop.
Horizontal annotations with ggrepel and ggplot2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
library(dplyr)
missing