I am generating multiple plots of different datasets in succession using MATLAB. I would like the legend positions to be such that they don't overlap on the plotted lines and it would be ideal if this placement could be done automatically.
I am aware of setting the 'Location'
to 'best'
to achieve this but the placement of the legend tends to be awkward when 'best'
is used (below). Also, I would like the legend to be inside the plot. I also came across a way to make the legend transparent (here) so that it does not render the plotted data invisible, but explicitly placing the legend elsewhere is what I am looking for.
Is there a way to place the legend at the extremes of the image ('NorthWest'
, 'SouthWest'
etc) automatically such that it does not overlap on the plotted data (apart from the methods suggested above)?