Adding shape-legend to ggplot2

Maybe the issue comes from defining shape both inside the aes() function and outside of it, if you want to have a legend then just do it inside aes(). Although, I can't test this since you are not providing sample data.

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.