How do I plot a contour map on the surface of a 3-d surface?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph
am 31 Jan. 2016
Kommentiert: GiWon Hong
am 14 Feb. 2020
The idea is similar to using "surf(X,Y,Z,C)" but I want contour lines in addition to the coloring provided by C. The contour lines need to correspond to f(x,y,z), not x, y, or z. If there is a non-toolbox specific answer, that would be great. Thanks.
0 Kommentare
Akzeptierte Antwort
Mike Garrity
am 1 Feb. 2016
Bearbeitet: Mike Garrity
am 1 Feb. 2016
A simple tricky I use sometimes is to use a colormap with a small number of colors.
[x,y] = meshgrid(linspace(-pi,pi,150));
z = cos(x).*cos(y);
c = sin(x).*sin(y);
surf(x,y,z,c,'FaceColor','interp','EdgeColor','none')
zlabel('cosine')
colormap(lines(7))
c = colorbar;
c.Label.String = 'sine';
view([-45 60])
3 Kommentare
John Mickett
am 7 Aug. 2019
I would like to put contour lines OVER a surf plot (two different variables), so that solution doesn't work. Any suggestions? I do it in 2D all the time.
GiWon Hong
am 14 Feb. 2020
Thanks, It is very helpful.
I used colormap(jet(31)) instead of colormap(lines(7)). It gives more contour likely view.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Contour Plots 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!