I have a histogram that is plotting 2 different groups with some overlap between them. I have been able to manually color the groups and a legend is generated for each group, however I am asking how to add into the legend a color and label for the overlapping part?
For example, in the above histogram I would like to add a legend for the purplish part where A and B overlap (which should be labeled as "Overlap" in the legend, underneath B).
Code for generating above histogram:
set.seed(42)
n <- 100
dat <- data.frame(id=1:n,
group=rep(LETTERS[1:2], n/2),
x=rnorm(n))
ggplot(dat, aes(x=x, fill=group)) + geom_histogram(alpha=.5, position="identity") +
scale_fill_manual(values=c("blue","red"))