Contour in a 3D surface plot

18 vues (au cours des 30 derniers jours)
Zhen Liu
Zhen Liu le 30 Mai 2020
Commenté : Zhen Liu le 21 Juin 2020
I am trying to creat a 3D surface plot with the contour of the surface projected on the top face (XY plane in Z = max)
Following is the code used:
f = figure('PaperSize',[8 8]);
Z = table2array(Table);
Z = Z(:,2:N+1);
Y = Table.Wavenumber_cm_1_;
X = [1:N];
SurfacePlot = surf(X,Y,Z);
ylabel('Wavenumber[cm^-1]');
xlabel('Aliquot Number');
zlabel('Absorbance[a.u.]');
colormap jet
shading interp
grid off;
hold on
contourf(X,Y,Z);
hold off
The problem is that the contour is created on XY plate (under the surface plot). How can move the contour up to the top surface?
Thank you.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 31 Mai 2020
Modifié(e) : Ameer Hamza le 31 Mai 2020
contour() object have an undocumented property named ContourZLevel: https://stackoverflow.com/a/8055468/4346708. For example,
[X,Y] = meshgrid(1:0.1:10,1:0.1:20);
Z = sin(X) + cos(Y);
ax = axes();
hold on
view(3);
s1 = surf(X,Y,Z);
[~, s2] = contourf(X,Y,Z);
s2.ContourZLevel = 5;
  1 commentaire
Zhen Liu
Zhen Liu le 21 Juin 2020
Thank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by