How i can add the color below the figure?

2 views (last 30 days)
Walaa on 4 Jun 2023
Edited: Star Strider on 4 Jun 2023

Answers (1)

Star Strider
Star Strider on 4 Jun 2023
Edited: Star Strider on 4 Jun 2023
If you are referring to the legend in the figure, it would be easiest to use the 'DisplayName' in every surf call so that the descriptions match correctly with the surface being plotted, otherwise you will need to provide the string arguments in the legend call itself.
The legend call should use 'Location','southoutside' with 'NumColumns',3, and 'Interpreter','latex' as its additional arguments. All these are explained in the documentation.
EDIT — (4 Jun 2023 at 14:08)
Simplified Example —
x = linspace(1, 4.5, 50);
y = linspace(-10, 10, 25);
[X,Y] = ndgrid(x, y);
Z1 = X.^5 * 1E+3;
Z2 = X.^3 * 1E+3;
surf(X, Y, Z1, 'FaceColor','b', 'DisplayName','$x^5$')
hold on
surf(X, Y, Z2, 'FaceColor','r', 'DisplayName','$x^3$')
hold off
legend('Location','southoutside', 'NumColumns',2, 'Interpreter','latex')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!