Change axis color on parts of the mesh

6 次查看(过去 30 天)
I would like this plot to have 2 colors on the same surface, meaning: blue between the x values of 1 and 2 and then between 9 and 10 and red on the rest of it.
Here's the code:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)

采纳的回答

Voss
Voss 2022-9-18
编辑:Voss 2022-9-18
Here's one way:
[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
C = 1 + (X <= 2 | X >= 9);
surf(X,Y,Z,C)
colormap([1 0 0; 0 0 1]);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by