Legends in MATLAB®
How to configure and style the legend in Plotly with MATLAB®.
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.
Note: We are retiring documentation for R, MATLAB, Julia, and F# in November 2025. Learn more about this change here.
Positioning Legends Inside the Plot
fig = figure; plot([1 2 3 4 5 6 7 8],[1 2 5 6 3 3 2 5]); hold on plot([1 2 3 4 5 6 7 8],[1 6 2 3 4 7 7 8]); legend('blue trace','orange trace'); fig2plotly(fig); Positioning Legends Outside the Plot
fig = figure; plot([1 2 3 4 5 6 7 8],[1 2 5 6 3 3 2 5]); hold on plot([1 2 3 4 5 6 7 8],[1 6 2 3 4 3 7 8]); legend('blue trace','orange trace','Location','BestOutside'); fig2plotly(fig);