How do I draw contour on the other two planes when using SURFC?

5 visualizaciones (últimos 30 días)
I use SURFC to plot my data(eg. peaks(30)) and the contour on xy plane looks great for knowing the maximum and minimum at some levels. But I also want to have contours on yz plane and zx plane. Is it possible to do that?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 9 de Abr. de 2013
The CONTOURSLICE may be an easy way to achieve this when you have the volume data for your surface plot. But if there's no volume data, it'll get more complex to do that. You'll do CONTOUR for each plane by changing the order of the input arguments and then swapping corresponding x/y/zdata of each contour line to achieve the effect. Please refer to the following example.
[X,Y,Z] = peaks(30);
h1=surfc(X,Y,Z);
xmin=-3;xmax=3;ymin=-3;ymax=3;zmin=-10;zmax=10;
axis([xmin xmax ymin ymax zmin zmax])
hold on;
%%contour on yz plane
[C,h]=contour(Y,Z,X);
hpatch = get(h,'Children');
for i = 1:length(hpatch)
ch = hpatch(i);
xdata = get(ch,'Xdata'); %
ydata = get(ch,'Ydata');
set(ch,'Xdata',zeros(size(xdata))+xmax);
set(ch,'Zdata',ydata);
set(ch,'Ydata',xdata);
end
%%contour on xz plane
[C,h]=contour(X,Z,Y);
hpatch = get(h,'Children');
for i = 1:length(hpatch)
ch = hpatch(i);
xdata = get(ch,'Xdata'); %
ydata = get(ch,'Ydata');
set(ch,'Ydata',zeros(size(ydata))+ymax);
set(ch,'Zdata',ydata);
set(ch,'Xdata',xdata);
end
For scatter data, you could also refer to related solution below "Is it possible to draw contour on YZ and ZX planes?".
  1 comentario
Walter Roberson
Walter Roberson el 13 de Mayo de 2020
Note: the above is valid only for HG1 -- that is, up to and including R2014a.
The instructions do not apply for R2014b and later, which draws contours differently.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Productos


Versión

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by