How i can add the color below the figure?

2 ビュー (過去 30 日間)
Walaa 2023 年 6 月 4 日
編集済み: Star Strider 2023 年 6 月 4 日
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 6 月 4 日
Draw the x-y plane and color accordingly.


回答 (1 件)

Star Strider
Star Strider 2023 年 6 月 4 日
編集済み: Star Strider 2023 年 6 月 4 日
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')


Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by