I belive I have set the xlim to start from April 29. But the output plot starts from April 1. How can I really force the graph to start from April 1?

 채택된 답변

Jakeb Chouinard
Jakeb Chouinard 2020년 12월 17일
편집: Jakeb Chouinard 2020년 12월 17일

0 개 추천

Once the figure is plotted, use xlim([x1,x2]) where x1 and x2 are in datetime form to force the graph's x-axis limits be x1 and x2.
See example below:
Where the minimum x-axis value is the thrid entry in the x datetime array and the maximum x-axis value is the last entry
For using datetick, try (if you want to keep the current tick locations):
datetick('x','mm/dd','keeplimits','keepticks')
If not, remove 'keepticks' and use:
set(gca,'XTicks',y) %where y is an array of values you want to use for your xticks in datetime form
xlim([x1,x2])
datetick('x','mm/dd','keeplimits')

댓글 수: 4

So this is what I find.
I comment out
datetick('x'.'mm/dd')
then true that the graph's x limit is forced on [x1 x2].
But if I activate the above datetick, then the graph will start from 04/20. What can be done?
Jakeb Chouinard
Jakeb Chouinard 2020년 12월 17일
편집: Jakeb Chouinard 2020년 12월 17일
Try (if you want to keep the current tick locations):
datetick('x','mm/dd','keeplimits','keepticks')
Otherwise, remove 'keepticks' and use:
set(gca,'XTicks',y) %where y is an array of values you want to use for your xticks in datetime form
xlim([x1,x2])
datetick('x','mm/dd','keeplimits')
alpedhuez
alpedhuez 2020년 12월 17일
whoa
Jakeb Chouinard
Jakeb Chouinard 2020년 12월 17일
whoah indeed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Calendar에 대해 자세히 알아보기

태그

질문:

2020년 12월 17일

편집:

2020년 12월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by