Plot where x axis is the date, Part 2 (edited)
이전 댓글 표시
I would like to have x axis of the plot between April 20 2016 and May 18 2018. Please advise how to modify an example
xlim(datetime(2014,[7 8],[12 23]))
xtickformat('dd-MMM-yyyy')
(https://www.mathworks.com/help/matlab/matlab_prog/plot-dates-and-durations.html)
to the above setting.
채택된 답변
추가 답변 (2개)
Nithin Banka
2018년 6월 5일
편집: Nithin Banka
2018년 6월 7일
Assuming that you have the same number of data points as the number of dates. Create a datetime vector for the duration and plot your data against the datetime vector.
datetimeVector = datetime(2016, 4, 20):datetime(2018, 5, 18);
plot(datetimeVector, yourData); %yourData is what you want to plot against the duration
xlim([datetimeVector(1) datetimeVector(end)]);
xtickformat('dd-MM-yyyy');
monika shivhare
2018년 6월 5일
xlim(datetime([2016 2018],[4 5],[20 18]))
xtickformat('dd-MMM-yyyy')
댓글 수: 2
alpedhuez
2018년 6월 5일
Nithin Banka
2018년 6월 7일
For this to work, you need the x-axis values to be in 'datetime' datatype or else, this gives an error.
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!