Main Content

일반적인2차원 플롯 생성하기

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

선플롯

plot함수는x값과y값으로 구성된 단순한 선 플롯을 만듭니다.

x = 0:0.05:5; y = sin(x.^2); figure plot(x,y)

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

선플롯은x,y데이터 세트를 여러 개 표시할 수 있습니다.

y1 = sin(x.^2); y2 = cos(x.^2); plot(x,y1,x,y2)

Figure contains an axes object. The axes object contains 2 objects of type line.

막대 플롯

bar함수는 세로 막대 차트를 만듭니다.barh함수는 가로 막대 차트를 만듭니다.

x = -2.9:0.2:2.9; y = exp(-x.*x); bar(x,y)

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

계단 플롯

stairs함수는 계단 플롯을 만듭니다. Y 값으로만 구성된 계단 플롯을 만들거나x,y값으로 구성된 계단 플롯을 만들 수 있습니다.

x = 0:0.25:10; y = sin(x); stairs(x,y)

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

오차 막대 플롯

errorbar함수는x,y값의 선 플롯을 그린 다음 각 관측값 위에 세로 오차 막대를 겹쳐 놓습니다. 오차 막대의 크기를 지정하려면 추가 입력 인수를errorbar함수로 전달하십시오.

x = -2:0.1:2; y = erf(x); eb = rand(size(x))/7; errorbar(x,y,eb)

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

극좌표 플롯

polarplot함수는 각도 값(단위: 라디안)theta대 반지름 값rho의 극좌표 플롯을 그립니다.

theta = 0:0.01:2*pi; rho = abs(sin(2*theta).*cos(2*theta)); polarplot(theta,rho)

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

줄기 플롯

stem함수는 공통 기준선에 세로선을 연결해x,y값에 대한 마커를 그립니다.

x = 0:0.1:4; y = sin(x.^2).*exp(-x); stem(x,y)

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

산점도 플롯

scatter함수는x,y값의 산점도 플롯을 그립니다.

loadpatientsHeightWeightSystolic散射(身高、体重)包含('Height') ylabel('Weight')

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

scatter함수에 선택적 인수를 사용하여 마커 크기와 색을 지정할 수 있습니다. 현재 좌표축에 색조를 표시하려면colorbar함수를 사용하십시오.

scatter(Height,Weight,20,Systolic) xlabel('Height') ylabel('Weight') colorbar

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

관련 항목