I would really appreciate some help with this. I completely do not understand how ggplot2 is thinking about legends!
The chart is based on the following data frame, called "meltdf":
xval variable value
1 0.000000 Shortfall Risk 100.00
2 4.624457 Shortfall Risk 99.83
3 9.179656 Shortfall Risk 60.96
4 13.742579 Shortfall Risk 36.29
5 18.620338 Shortfall Risk 27.71
6 22.947704 Shortfall Risk 22.52
7 27.690638 Shortfall Risk 19.72
8 32.174379 Shortfall Risk 17.89
9 36.637940 Shortfall Risk 15.79
10 41.107962 Shortfall Risk 15.96
11 45.644065 Shortfall Risk 15.97
The chart is drawn as follows:
ggplot(data=meltdf,aes(x=xval,y=value))+
geom_line(size=1,colour=rgb(69,99,111,max=255))+
geom_vline(xintercept = 22 ,colour="darkgray")+
geom_vline(xintercept = 30 ,colour="darkred")+
theme_bw()+
labs(title="Shortfall Risk versus Investment Risk, Meeting Expenditure Only")+
theme(legend.position="bottom",
legend.text = element_text(size=9),
axis.text = element_text(size=9),
axis.title = element_text(size=9),
plot.title=element_text(size = 9),
legend.title=element_text(size=9))+
labs(x="Largest Historical Decline (%)", y="Probability of Shortfall (%)")+
scale_y_continuous(limits = c(0, 100))
I would like to have a legend at the bottom in which all three lines in the chart (blue, red and grey) are named.