Have you tried simply expanding the plot to be wider, by giving the plot window more space ? you might find that the legend goes to its natural position when there is sufficient room.
If this doesn't work or is unsatisfactory, I would be willing to try to come up with some code for you to control it more explicitly but I would ask that you make a reprex first.
Read about how to do that here : link