필터 지우기
필터 지우기

How do I change numbers on the x-axis?

조회 수: 71 (최근 30일)
Shane
Shane 2014년 6월 26일
댓글: Deepak Sapkota 2020년 7월 18일
I want to switch from matlabdate to hours. So 0.5 matlabdate on the x-axis should be 12 hours. How do I do this without messing up the plot?

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 6월 26일
Try changing the XTickLabels of the axis. To view the current x tick labels, in the Command Window type
get(gca,'XTickLabel')
This should return a list of the labels along the x-axis. Note that gca is for "get current axis" and so we assume that the plot whose x-axis labels that you want to change has focus (not some other figure).
Then to change the labels, just provide a new list of the same size and set it via
set(gca,'XTickLabel',[0 12 24 36 48])
Just remember that your new list must have a replacement for each element in the original list.
  댓글 수: 1
Deepak Sapkota
Deepak Sapkota 2020년 7월 18일
Great, this worked for me. Thanks Geoff.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by