If I have the following plot, how would I place the color (error) legend item below the fill (yr) one?
library(dplyr)
library(ggplot2)
dat <- data.frame(yr = c(2017:2019) %>% as.factor,
val = 1:3)
dat %>%
ggplot(aes(x = yr, y = val, fill = yr)) +
geom_bar(stat = "identity") +
geom_errorbar(aes(ymin = 7, ymax = 7,
color = "Error")) +
theme(legend.position = "bottom")