I need a little help with this 3d plot contour.
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/965250/image.jpeg)
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
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!