Set x-axis interval

조회 수: 34 (최근 30일)
ImpactMike
ImpactMike 2020년 6월 10일
댓글: Ameer Hamza 2020년 6월 12일
Hi,
I'm just a bit confused about how to set the interval on my x-axis, to ensure that my graph is plotted in increments of 1 instead of decimals.
I have reviewed other posts but my situation is slightly different because I have multiple graphs to plot, using a control loop. So I would like every graph to have an interval of 1 on the x-axis.
Saw this on a related post and tried it but it didn't work --> set(gca,'XTick',(INTERVAL)).
Please help.
Thank you

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 6월 10일
편집: Ameer Hamza 2020년 6월 10일
You can use xticks function in R2016b and later
current_ticks = xticks;
xticks(round(min(current_ticks)):1:round(max(current_ticks)));
earlier releases
current_ticks = get(gca, 'XTick');
set(gca, 'XTick', round(min(current_ticks)):1:round(max(current_ticks)));
  댓글 수: 2
ImpactMike
ImpactMike 2020년 6월 11일
Thank you so much for this Ameer! Much appreciated x
Ameer Hamza
Ameer Hamza 2020년 6월 12일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by