Legend best fit
legend_best_fit automatically positions the existing legend inside the axes to avoid covering the plotted data. I think it does a better job than the "Location", "Best" option in "legend" command.
Example:
legend_best_fit(axes_handle)
Will position legend inside if it can, return false if it can not.
legend_best_fit(axes_handle, 'adjust y limits', true)
Positions legend if it can with existing y axis limits. If not, slightly expands y axis limits & tries again.
legend_best_fit(axes_handle, 'location', preferred_location)
Tries your preferred location (like "NorthEast", etc.) first.