Change colour on grid

3 ビュー (過去 30 日間)
Andrew
Andrew 2025 年 4 月 23 日
コメント済み: Mathieu NOE 2025 年 4 月 24 日
Hi,
How would I change the colour of the little square island in my waves simulation?

採用された回答

Mathieu NOE
Mathieu NOE 2025 年 4 月 23 日
hello Andrew
one solution is to overlay two mesh plots and ask for the second to have a single bright color (here red)
either only the mesh is red but you can also have plain (face) color as shown in the second example :
[X,Y] = meshgrid(-15:.5:15);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R).*R;
[m,n] = size(Z);
% create inner flat square
ind = round(m/2) + (-10:10);
Z(ind,ind) = 0;
figure
mesh(X,Y,Z)
hold on
m = mesh(X(ind,ind),Y(ind,ind),Z(ind,ind));
set(m,'Edgecolor','r');
% set(m,'Facecolor','r');
view(-30,75)
hold off
figure
mesh(X,Y,Z)
hold on
m = mesh(X(ind,ind),Y(ind,ind),Z(ind,ind));
set(m,'Edgecolor','r');
set(m,'Facecolor','r');
view(-30,75)
hold off
  2 件のコメント
Andrew
Andrew 2025 年 4 月 24 日
移動済み: Mathieu NOE 2025 年 4 月 24 日
That is great thank you
Mathieu NOE
Mathieu NOE 2025 年 4 月 24 日
as always, my pleasure

サインインしてコメントする。

その他の回答 (1 件)

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2025 年 4 月 23 日
The colour is going to be related to the values of whatever you are plotting, e.g.,
L = 160*membrane(1,100);
mesh(L)
colorbar
The blue is due to the values in the square region, and it is related to the colormap that you use. You may play with the colormaps to change those values but you will be affecting all the values.
figure
mesh(L)
colorbar
colormap jet
Hope this helps.
  1 件のコメント
Andrew
Andrew 2025 年 4 月 24 日
Thanks

サインインしてコメントする。

カテゴリ

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

タグ

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by