I need a little help with this 3d plot contour.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tamás Zsombor Tolvaj
am 15 Apr. 2022
Kommentiert: Tamás Zsombor Tolvaj
am 15 Apr. 2022

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 Kommentare
Akzeptierte Antwort
Dyuman Joshi
am 15 Apr. 2022
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
