I need my legend to be inside the plot itself (for space reasons). Currently I have the legend hardcoded to specific position using legend.position = c(.85,.75)
.
I am making hundreds of variations these plots and sometimes the lines being plotted end up being covered by the legend. However since I am making hundreds it also means I don't have time to manually go through and change the legend position for every variation with this issue.
Is there an existing option for legend position that puts the legend in the plot area but is smart enough to move the legend so it doesn't cover any of the plotted data? I know there are some ways when labeling points to make sure they jitter so they don't cover any data and I am curious if something similar exists for the legend?