Change axis color on parts of the mesh

조회 수: 2 (최근 30일)
Alexandra Roxana
Alexandra Roxana 2022년 9월 18일
댓글: Voss 2022년 9월 19일
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]);
  댓글 수: 2
Alexandra Roxana
Alexandra Roxana 2022년 9월 18일
Great and easy! Thanks a lot!
Voss
Voss 2022년 9월 19일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (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