I did a CDP plot with stat_ecdf function, but I cannot add a legend. This is the code of the CDP plot:
ggplot()+
stat_ecdf(data=df, aes(Apple), geom = "step", col ="red")+
stat_ecdf(data=df, aes(Ocean), geom = "step", col ="blue")+
stat_ecdf(data=df, aes(Tree), geom = "step", col ="green")+
stat_ecdf(data=df, aes(Citron), geom = "step", col ="yellow")+
stat_ecdf(data=df, aes(Sun), geom = "step", col ="orange")+
labs(y="Cumulative Probability",x="Proportion of samples (>1 FIB per 100 mL)",col="Legend")+
theme_classic()
The plot appears, but no legend. I would like to have a legend which describes that the red line = apple, blue line = ocean, etc. Thank you.