Hi everbody,
I have a plot of 31 data points. However, instead of labeling the x-axis is (1:1:31), I want to set it to (-6:1:24). How can I do that?
Best

 채택된 답변

Joseph Cheng
Joseph Cheng 2015년 5월 21일

0 개 추천

solved much simpler by going
figure,plot(-6:24,1:31)
because you're setting the x and y plot pairs.

추가 답변 (3개)

the cyclist
the cyclist 2015년 5월 21일
편집: the cyclist 2015년 5월 21일

0 개 추천

set(gca,'XTick',-6:24,'XTickLabel',-6:24);
Note that that command is doing two things in one line. It defining tick mark positions, and also relabeling them.

댓글 수: 2

Christian F.
Christian F. 2015년 5월 21일
Thank you for the quick response but somehow I can't get it to work.
Take for example:
plot(1:1:31);
set(gca,'XTick',-6:24,'XTickLabel',-6:24);
The x-axis is somehow messed up
the cyclist
the cyclist 2015년 5월 21일
편집: the cyclist 2015년 5월 22일
figure
plot(1:1:31);
set(gca,'XLim',[-6 24],'XTick',-6:24,'XTickLabel',-6:24);
This fixes my solution, but I think the other answers here are actually what you wanted, aligning your 31 data points with the x-axis points -6:24.

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

Nazmi Rosly
Nazmi Rosly 2021년 8월 13일

0 개 추천

Hi. im displaying my data from serial monitor arduino for temperature monitoring. So now it show the temperature vs second on the graph. Is there any command to change the seconds to current time like maybe 12.45 instead of its displaying 200 second.

댓글 수: 1

the cyclist
the cyclist 2021년 8월 13일
You have posted this question as an "answer" on a 6-year-old question that is unrelated. Instead, you should post a new question.

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

카테고리

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

태그

질문:

2015년 5월 21일

댓글:

2021년 8월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by