how to plot the time series data with dates showing in x axis
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
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
figure
Ts = timeseries(Ta);
plot(Ts,'r')
grid on
grid minor
xlabel('Time','fontsize',14)
ylabel('Temperature (\circC)','fontsize',14)
Problem, cannot manage date lable, you can find attached file may show me how it's work.
채택된 답변
Cris LaPierre
2020년 3월 18일
편집: Cris LaPierre
2020년 3월 18일
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")
plot(Time,Ta)
댓글 수: 14
Dear Cris, tnx
it should be ....,'excel')
Dear Cris,
Years has been displayed form of 0066-May, 0066-Jun,0067-Jan,...etc. I would to be 2016-May, 2016-Jun, ...etc. Year reference is 1950. You know how can I do it?
Cris LaPierre
2020년 3월 19일
편집: Cris LaPierre
2020년 3월 19일
Interesting. The code I shared imports the year as 1966, 1967, etc for me.
For me, your vector time appears to be in units of days. So if the reference data is 01-01-1950, the first date is around 12-06-2016. Does that sound correct?
If your time does not correspond to a built-in option, you can specity your own epoch. However, this appears to expect the time values to be in seconds, not days. You can modify the datetime conversion to the following to account for this:
% Convert time from days to seconds for conversion. Reference is 1950
Time = datetime(time*60*60*24,'ConvertFrom','epochtime','Epoch','1950-01-01')
Dear Cris,
I really appreciate your patience, Time reference is "1950-01-01T00:00:00Z". I want to be in format "mmm-yyyy", and also "dd-mmm-yyyy" , thanks.
Dear Cris, I fixed the date, proble is plotting. Could you tell me how can I fixed it. Thanks
>> pcolor(Time,-P,T);shading flat;colorbar; colormap(jet)
Error using pcolor (line 63)
Data inputs must be real.
Cris LaPierre
2020년 3월 19일
편집: Cris LaPierre
2020년 3월 19일
I don't know what P and T are, so I can't reproduce your error. Perhaps this post can help with the error you are seeing? Especially if you are using MATLAB r2019a or older.
Dear Cris, I attached P(pressure) and T(temperature). I really appreciate your help. Thanks.
And what version of MATLAB are you using? If 2019a or earlier, look at the two posts I've already shared that show you how to fix this.
Matlab2016
Dear Cris, I really appreciate. I could fixed it
figure
pcolor(datenum(Time),-P,S);shading flat;colorbar
datetick('x', 'yyyy-mmm', 'keepticks')
(thanks)^10000000
Very good! Glad you got it working.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
