I would like to add the labels to the x-axis for the data from the geom_vline layer without having to regenerate the existing ones:
library(dplyr)
library(ggplot2)
data_frame(x = rnorm(10000)) %>%
ggplot(aes(x = x)) +
geom_histogram(bins = 100) +
geom_vline(aes(xintercept = mean(x) + 2.6)) +
theme_bw()

You could do this:
library(dplyr)
library(ggplot2)
data_frame(x = rnorm(10000)) %>%
ggplot(aes(x = x)) +
geom_histogram(bins = 100) +
geom_vline(aes(xintercept = mean(x) + 2.6)) +
theme_bw() +
geom_text(aes(x=mean(x) + 2.6, label="My label text", y=0), colour="blue", angle=90)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With