Plotting a time series with shaded regions

조회 수: 1 (최근 30일)
Linden
Linden 2014년 5월 16일
답변: Yao Li 2014년 5월 16일
Hi I want plot a time series (see below) with shade strips in the background. For example, if the data belongs to 1998, add a light grey strip behind the line. If it belongs to 1999, add a darker grey stripe behind the line and so on. I would also like to have a text box on each strip indicating the period of time. It seems to be a very challenging task for me. can someone help me?
thanks very much.
'6/01/1998' [ 5.41]
'9/01/1998' [5.0933]
'12/01/1998' [ 4.39]
'3/01/1999' [4.6633]
'6/01/1999' [ 4.88]
'9/01/1999' [ 5.16]
'12/01/1999' [5.6067]
'3/01/2000' [6.1867]
'6/01/2000' [6.2167]
'9/01/2000' [ 6.13]
'12/01/2000' [ 5.9]
'3/01/2001' [4.5967]
'6/01/2001' [ 3.78]

답변 (1개)

Yao Li
Yao Li 2014년 5월 16일
time='6/01/1998';
fwd_slash_loc=strfind(time,'/');
year=time(fwd_slash_loc(2)+1:end);

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by