I'm trying to automatically place a legend box in a plot, but I'm still in trouble with it. I'd like to place the legend box close to the corner of the plot, but with a small padding/margin.
Using predefined positions, like "topright"
or "bottomleft"
, place the legend too close/upon the border of the plot, like here;
and I find it amazingly upsetting to keep on trying pixel by pixel to reach a nice placement to the box, as shown here.
I was wondering if there was anyway to position the legend box based on the width of the plot itself, and not on max/min
values. Something that would automatically position the legend about p%
close to a defined corner. Is there anyway to do so in R? Or even a way to add some padding to predefined positions?