Main Content

plot

timeseries 플로팅

설명

예제

plot(ts)는 시간에 대해 tstimeseries 데이터를 플로팅하고, 샘플 간의 값을 보간합니다.

예제

plot(ts,LineSpec)은 선 그래프를 사용하여 timeseries 데이터를 플로팅하고 지정된 specs를 선, 마커 또는 둘 모두에 적용합니다.

이름-값 인수를 지정하여 Line 속성을 정의할 수도 있습니다.

예제

모두 축소

시계열 객체를 만들고 시작 날짜를 설정한 다음, 시작 날짜를 기준으로 시간 벡터를 플로팅합니다.

x = [2 5 8 2 11 3 6];
ts1 = timeseries(x,1:7);

ts1.Name = 'Daily Count';
ts1.TimeInfo.Units = 'days';
ts1.TimeInfo.StartDate = '01-Jan-2011';     % Set start date.
ts1.TimeInfo.Format = 'mmm dd, yy';       % Set format for display on x-axis.

ts1.Time = ts1.Time - ts1.Time(1);        % Express time relative to the start date.

plot(ts1)

Figure contains an axes object. The axes object with title Time Series Plot:Daily Count, ylabel Daily Count contains an object of type line.

교통량 데이터에서 두 개의 시계열 객체를 만든 다음 같은 좌표축에 차례로 플로팅합니다. 이 중 한 시계열 객체에, 빨간색 마커로 자동으로 표시되는 이벤트를 추가합니다.

load count.dat;
count1 = timeseries(count(:,1),1:24);
count1.Name = 'Oak St. Traffic Count';
count1.TimeInfo.Units = 'hours';
plot(count1,':b')
grid on

Figure contains an axes object. The axes object with title Time Series Plot:Oak St. Traffic Count, xlabel Time (hours), ylabel Oak St. Traffic Count contains an object of type line.

최댓값의 시간을 구하여 이벤트로 추가합니다.

[~,index] = max(count1.Data);
max_event = tsdata.event('peak',count1.Time(index));
max_event.Units = 'hours';

이 이벤트를 시계열에 추가합니다.

count1 = addevent(count1,max_event);

기존 플롯을 이벤트를 표시하는 새 플롯으로 바꿉니다.

plot(count1,'.-b')
grid on

Figure contains an axes object. The axes object with title Time Series Plot:Oak St. Traffic Count, xlabel Time (hours), ylabel Oak St. Traffic Count contains 2 objects of type line. One or more of the lines displays its values using only markers

동일한 데이터 소스의 열 2에서 새로운 시계열 객체를 만듭니다.

count2 = timeseries(count(:,2),1:24);
count2.Name = 'Maple St. Traffic Count';
count2.TimeInfo.Units = 'Hours';

hold를 on으로 설정하여 새 데이터를 플롯에 추가합니다.

hold on

plot 메서드는 유지된 플롯에 레이블을 추가하지 않습니다. 속성/값 쌍을 사용하여 마커를 사용자 지정합니다.

plot(count2,'s-m','MarkerSize',6),

Figure contains an axes object. The axes object with title Time Series Plot:Oak St. Traffic Count, xlabel Time (hours), ylabel Oak St. Traffic Count contains 3 objects of type line. One or more of the lines displays its values using only markers

레이블이 지워졌으므로 수동으로 생성합니다.

title('Time Series: Oak Street and Maple Street')
xlabel('Hour of day')
ylabel('Vehicle count')

왼쪽 위에 범례를 추가합니다.

legend('Oak St.','Maple St.','Location','northwest')

Figure contains an axes object. The axes object with title Time Series: Oak Street and Maple Street, xlabel Hour of day, ylabel Vehicle count contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Oak St., Maple St..

입력 인수

모두 축소

입력 timeseries로, 스칼라로 지정됩니다.

선 스타일, 마커, 색으로, 기호를 포함하는 string형 스칼라 또는 문자형 벡터로 지정됩니다. 기호는 어떤 순서로 지정해도 좋습니다. 세 가지 특성(선 스타일, 마커, 색)을 모두 지정할 필요는 없습니다. 예를 들어 선 스타일을 생략하고 마커를 지정하면 플롯은 마커만 표시하고 선은 표시하지 않습니다.

예: "--or"은 원 마커로 표시된 빨간색 파선입니다.

선 스타일설명결과 선
"-"실선

Sample of solid line

"--"파선

Sample of dashed line

":"점선

Sample of dotted line

"-."일점 쇄선

Sample of dash-dotted line, with alternating dashes and dots

마커설명결과로 생성되는 마커
"o"

Sample of circle marker

"+"플러스 기호

Sample of plus sign marker

"*"별표

Sample of asterisk marker

"."

Sample of point marker

"x"십자

Sample of cross marker

"_"가로선

Sample of horizontal line marker

"|"세로선

Sample of vertical line marker

"square"정사각형

Sample of square marker

"diamond"다이아몬드

Sample of diamond marker

"^"위쪽 방향 삼각형

Sample of upward-pointing triangle marker

"v"아래쪽 방향 삼각형

Sample of downward-pointing triangle marker

">"오른쪽 방향 삼각형

Sample of right-pointing triangle marker

"<"왼쪽 방향 삼각형

Sample of left-pointing triangle marker

"pentagram"펜타그램

Sample of pentagram marker

"hexagram"헥사그램

Sample of hexagram marker

색 이름짧은 이름RGB 3색모양
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

  • plot 함수는 제목과 축 레이블을 자동으로 생성합니다. 이러한 축 레이블은 다음과 같습니다.

    • 플롯 제목 — 'Time Series Plot: <name>'

      여기서 <name>ts.Name에 할당된 문자열이거나 기본적으로 'unnamed'입니다.

    • X축 레이블 — 'Time (<units>)'

      여기서 <units>ts.TimeInfo.Units 필드의 값이며, 디폴트 값은 'seconds'입니다.

    • Y축 레이블 — '<name>'

      여기서 <name>ts.Name에 할당된 문자열이거나 기본적으로 'unnamed'입니다.

  • hold on을 설정하고 다른 timeseries/plot 명령을 실행하는 방식으로 시계열 플롯에 새로운 시계열 데이터를 배치할 수 있습니다. 플롯에 데이터를 추가하면 레이블 지정 혼동을 피하기 위해 제목과 축 레이블이 빈 문자열이 됩니다. title, xlabel, ylabel 명령을 사용하여, 플로팅 후에 사용자 자신의 레이블을 추가할 수 있습니다.

  • 시계열 이벤트는(정의된 경우) 빨간색으로 채워진 원형 마커로 플롯에 표시됩니다. 데이터에 의해 정의된 이벤트 마커 외에, linespec 또는 이름/값 구문을 사용하여 모든 데이터 점에 대해 마커를 지정할 수도 있습니다. 이벤트 마커는 사용자가 정의한 마커 위에 플로팅됩니다.

  • ts.DataInfo.Interpolation.Name에 할당된 값은 시계열 데이터를 플로팅하고 리샘플링할 때 plot 메서드가 사용하는 보간 유형을 제어합니다. 디폴트 선형 보간을 영차 유지(Zero-Order Hold) 보간(계단식)으로 변경하려면 timeseries 메서드 setinterpmethod를 불러오십시오. 이 메서드는 원하는 경우 사용자가 원래 객체를 덮어쓰는 데 사용할 수 있는 새로운 timeseries 객체를 생성합니다. 예를 들어, 시계열 ts가 영차 유지(Zero-Order Hold) 보간을 사용하도록 하려면 다음을 입력하십시오.

    ts = ts.setinterpmethod('zoh');

버전 내역

R2006a 이전에 개발됨