Move the legend outside the plot (to avoid covering the data) but on top (to avoid squeezing the plot to make room) and underneath the title. (Because I think having the legend above the title looks awkward.)
Kevin J. Delaney (2021). Place legend outside the plot, beneath the title (https://www.mathworks.com/matlabcentral/fileexchange/41746-place-legend-outside-the-plot-beneath-the-title), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!