plot the time series data
1 view (last 30 days)
Show older comments
Hi all, I am trying to plot the monthly time series in the same graph with x axis representing month of year and y axis the time series of data1 and data2 . In the original excel file tss.xlsx are 3 sheets,each has one column(303 rows) of data with names as sheet1:dates( from 07.1990to 09.2015), sheet2: data1, sheet3:data2. Data is shown as below
tss=
1990/7/31 1.007180601 0.955050804
1990/8/31 0.986132061 0.930056005
1990/9/28 1.143781772 0.944318813
1990/10/31 1.180854071 0.970127084
1990/11/30 1.144684607 0.926718054
1990/12/31 0.958882349 0.870540688
....
2015/7/30 0.800130487 0.819143168
2015/8/31 0.787216726 0.862432198
2015/9/28 0.904850084 0.948935783
I first import the data into matlab and further run the codes as follows
dates=xlsread('tss.xlsx','dates');
data1=xlsread('tss.xlsx','data1');
data2=xlsread('tss.xlsx','data2');
plot(tss(1:303,1),data1,tss(1:303,1),data2)
datetick('x', 'mmmyy', 'keeplimits', 'keepticks')
legend('ts of data1','ts of data2')
grid on
grid minor
I am not satisfied with plotting 1) The x axis does show every year..I need an x.axis which is labeled from year 1990 to year 2015, with grid of 1 year only. 2) The x axis begins from year 1987 and ends at 2020, but I want the plotting to start in 1990 and ends at 2015. Could you help me to figure out the above questions please? Thank you very much.
Best Jessie
0 Comments
Answers (1)
Robert
on 11 Jan 2016
To set your own x-axis limits, use the xlim function. To control the labels on the x-axis, you need to set the XTick property.
set(gca,'XTick',[1,2,3,4,5,...])
Of course, you will need real values for XTick.
0 Comments
See Also
Categories
Find more on Measurements and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!