MATLAB Answers

how to plot the time series data with dates showing in x axis

6 views (last 30 days)
I can plot time series but I am not able to show exact dates on x axis. I really appreciate anybody can help me. Thanks
Ts = timeseries(Ta);
grid on
grid minor
ylabel('Temperature (\circC)','fontsize',14)
Problem, cannot manage date lable, you can find attached file may show me how it's work.


Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 18 Mar 2020
Edited: Cris LaPierre on 18 Mar 2020
Convert your dates to the datetime data type. Then, when you plot using the datetime, the date will appear on the axis. You can set the display format of a datetime to show the date however you'd like.
load example.mat
Time = datetime(time,'ConvertFrom',"excel")
You may need to adjust the ConvertFrom datatype. I didn't know, so I just selected a common one.


Farshid Daryabor
Farshid Daryabor on 19 Mar 2020
Dear Cris, I really appreciate. I could fixed it
pcolor(datenum(Time),-P,S);shading flat;colorbar
datetick('x', 'yyyy-mmm', 'keepticks')

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Translated by