Main Content

3차원 플롯 생성

이 예제에서는 MATLAB®에서 다양한 3차원 플롯을 생성하는 방법을 보여줍니다.

메시 플롯

mesh 함수는 와이어프레임 메시를 생성합니다. 기본적으로 메시의 색은 곡면 높이에 비례합니다.

z = peaks(25);

figure
mesh(z)

Figure contains an axes object. The axes object contains an object of type surface.

곡면 플롯

surf 함수는 3차원 곡면 플롯을 만드는 데 사용됩니다.

surf(z)

Figure contains an axes object. The axes object contains an object of type surface.

곡면 플롯(음영 포함)

surfl 함수는 컬러맵 기반의 조명 효과가 있는 곡면 플롯을 생성합니다. 색이 좀 더 매끄럽게 전환되도록 하려면 pink 같이 선형 농도 변화가 있는 컬러맵을 사용하십시오.

surfl(z)
colormap(pink)    % change color map
shading interp    % interpolate colors across lines and faces

Figure contains an axes object. The axes object contains an object of type surface.

등고선 플롯

contour 함수는 상수 값의 등고선으로 구성된 플롯을 만드는 데 사용됩니다.

contour(z,16)
colormap default    % change color map

Figure contains an axes object. The axes object contains an object of type contour.

퀴버 플롯

quiver 함수는 2차원 벡터를 화살표로 플로팅합니다.

x = -2:.2:2; 
y = -1:.2:1;

[xx,yy] = meshgrid(x,y);
zz = xx.*exp(-xx.^2-yy.^2);
[px,py] = gradient(zz,.2,.2);

quiver(x,y,px,py)
xlim([-2.5 2.5])    % set limits of x axis

Figure contains an axes object. The axes object contains an object of type quiver.

3차원 볼륨을 자르는 슬라이스

slice 함수는 볼륨 데이터를 자르는 슬라이스 평면에 데이터를 표시합니다.

x = -2:.2:2;
y = -2:.25:2;
z = -2:.16:2;

[x,y,z] = meshgrid(x,y,z);
v = x.*exp(-x.^2-y.^2-z.^2);

xslice = [-1.2,.8,2];    % location of y-z planes
yslice = 2;              % location of x-z plane
zslice = [-2,0];         % location of x-y planes

slice(x,y,z,v,xslice,yslice,zslice)
xlabel('x')
ylabel('y')
zlabel('z')

Figure contains an axes object. The axes object with xlabel x, ylabel y contains 6 objects of type surface.