How do I draw contour on the other two planes when using SURFC?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 9 Apr. 2013
Kommentiert: Walter Roberson
am 13 Mai 2020
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?
Akzeptierte Antwort
MathWorks Support Team
am 9 Apr. 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 Kommentar
Walter Roberson
am 13 Mai 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.
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!