Plotting a time series with shaded regions

3 vues (au cours des 30 derniers jours)
Linden
Linden le 16 Mai 2014
Réponse apportée : Yao Li le 16 Mai 2014
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]

Réponses (1)

Yao Li
Yao Li le 16 Mai 2014
time='6/01/1998';
fwd_slash_loc=strfind(time,'/');
year=time(fwd_slash_loc(2)+1:end);

Community Treasure Hunt

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

Start Hunting!

Translated by