フィルターのクリア

I need a little help with this 3d plot contour.

1 回表示 (過去 30 日間)
Tamás Zsombor Tolvaj
Tamás Zsombor Tolvaj 2022 年 4 月 15 日
The task is about islands, which I managed to plot in 3d, but I have a small issue with the contour part.
This is the contoured map of our task, and I dont know how I can color the areas between -2 and 0 with green. Areas below -5 need to be blue, which I could solve, but I dont know how I can do it with green parts. The code looks like this, and the only problem I have is the coloring:
x=-4:0.1:4;
y=-4:0.1:4;
[X, Y] = meshgrid(x,y);
Z = 2*(peaks(X, Y)-3);
[C,U,V,W,fig1,plt1,plt2,fig2,plt3,cl] = tengerpart(X,Y,Z); %this is the call function
function [C,U,V,W,fig1,plt1,plt2,fig2,plt3,cl] = tengerpart(X,Y,Z)
fig2=figure(2); %and this is my try for it
map=[0 0 1; 0 1 0; 1 1 1; 0 1 0];
colormap(map);
v=[-25, -5, -2, 0];
plt3=contourf(X, Y, Z, v);
xlim([-4 4]);
ylim([-4 4]);
cl=clabel(plt3, v);
end

採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 4 月 15 日
x=-4:0.1:4;
y=-4:0.1:4;
[X, Y] = meshgrid(x,y);
Z = 2*(peaks(X, Y)-3);
fig2=figure(2);
map=[0 0 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 0 1 0; 1 1 1];
colormap(map);
v=[-25, -5, -2, 0];
plt3=contourf(X, Y, Z, v);
xlim([-4 4]);
ylim([-4 4]);
cl=clabel(plt3, v);
colorbar
  1 件のコメント
Tamás Zsombor Tolvaj
Tamás Zsombor Tolvaj 2022 年 4 月 15 日
Thank you, it works properly now!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by