Move a contour plot down to a specific z value?

30 visualizzazioni (ultimi 30 giorni)
dylan il 12 Mag 2013
Risposto: Angelo Yeo il 25 Gen 2023
I want to move a contour plot down to a z=-4 value.
I have tried csurf, however that does not work, because it puts it all the way on the bottom, and it is not correctly in line with my surface for some reason.
]
]
function PlotSurface
[x,y] = meshgrid(-4:.05:4);
z = 3*(1-x).^2.*exp(-(x.^2) - (y+1).^2)- 10*(x/5 - x.^3 - y.^5).*exp(-x.^2-y.^2)- 1/3*exp(-(x+1).^2 - y.^2);
surf(x,y,z,'EdgeColor','none')
hold all
axis([-4,4,-4,4,-8,8])
contour(x,y,z,30) %%%%<< I want to move this to Z=-4 and it is on Z=0 now >>%%%
end
]
]
Dylan
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Risposte (3)

Tue Chasin il 6 Ago 2014
1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Jörg Bäuerle il 27 Mar 2015
The solution posted in that stackoverflow thread didn't work for me in Matlab 2015a. Does anybody have any other ideas how to move the contours down the z-axis?
Thanks a lot in advance, Joerg

Accedi per commentare.

Walter Roberson il 12 Mag 2013
Instead of supplying a scalar of the number of contours you want, you can provide a vector of the values at which you want the contour lines to be drawn.
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Angelo Yeo il 25 Gen 2023
As of R2022b, consider the following example script:
x = -2:0.25:2;
y = x;
[X,Y] = meshgrid(x);
F1 = X.*exp(-X.^2-Y.^2);
figure;
surf(X, Y, F1);
hold on;
[~, h] = contour(X,Y,F1);
h.ZLocation = "zmin";
xlabel('x-axis'); ylabel('y-axis'); zlabel('z-axis')
grid on;
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by