In ggplot2 legends are tied to aesthetics to my knowledge and I believe that may be my problem here, but I cannot figure out the solution as to why my legend isn't showing. I've read other posts made adjustments, but still cannot get them to show.
Any suggestions are appreciated.
rawAuto data below
LoanType Excessive Income LoanStatus
1: VL 0 0 WITHDRAWN
2: VL 0 0 WITHDRAWN
3: VL 0 0 WITHDRAWN
4: VL 0 0 WITHDRAWN
5: VL 1 0 DECLINED
6: VL 0 0 WITHDRAWN
7: VL 1 0 DECLINED
8: VL 0 0 WITHDRAWN
9: VL 0 0 INSTANT APPROVED
10: VL 0 0 WITHDRAWN
11: VL 0 0 INSTANT APPROVED
12: VL 0 0 PRE-APPROVED
13: VL 0 0 WITHDRAWN
14: VL 0 0 INSTANT APPROVED
15: VL 0 0 INSTANT APPROVED
16: VL 0 0 INSTANT APPROVED
17: VL 0 0 PRE-APPROVED
18: VL 0 0 INSTANT APPROVED
19: VL 1 0 DECLINED
20: VL 0 0 WITHDRAWN
ggplot(rawAuto, aes(LoanStatus)) +
stat_count(aes(LoanStatus, y = ..count..), show.legend = T,
geom = "bar", color = "grey") +
stat_count(data = rawAuto[Excessive == 0 & Income == 0], aes(LoanStatus, y = ..count..),
geom = "point", color = "red", show.legend = T) +
scale_size_continuous(range = c(4, 8)) +
scale_y_continuous(labels = comma, breaks =
c(0,600,1200,1800,2400,3000,3600,4200,4800,5400,6000)) +
labs(title = "Total auto applications vs. excluding 'Excessive' and
'Insufficient Income' denial reasons", x = "Loan Status",
y = "Auto loan Counts") +
theme(axis.text.y = element_text(size = 15)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_colour_manual(name = 'Legend', values = c("grey"= "grey",
"red"= "red"), labels = c('All auto','Subset auto'))