I'm looking to rotate the legend of a plot from vertical lines to horizontal but keep the actual lines vertical in the graph. There are a number of hack type solutions but I think this can now easily be done with ggstance
package but I'm not sure how to achieve it.
library(tidyverse)
library(ggstance)
df <- tibble(x = rnorm(40))
df_stats <-
df %>% summarise(
mean = mean(x),
median = median(x)
) %>%
gather(key = legend, value = value, mean:median)
df %>%
ggplot(aes(x = x)) +
geom_histogram(bins = 20) +
geom_vline(data = df_stats, aes(xintercept = value, color = legend))
Any suggestions using ggstance
? thanks
EDIT per @Allan Cameron comment
As ggstance
has been superseded by the latest version of ggplot, I'm happy to see any solution someone might have?