I need a little help with this 3d plot contour.
조회 수: 1 (최근 30일)
이전 댓글 표시
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에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!