필터 지우기
필터 지우기

Fix x axis on plot

조회 수: 1 (최근 30일)
Michael
Michael 2011년 7월 19일
Hey, so I have a plot that displays data for a year starting from week 28 of a year and then going to week 27 of the next year. So I have excel data that runs from 28 to 52 and then 1 to 27. but when I plot it in matlab it rearranges the data so that it goes from 1 to 52? DO you know how I can fix this?

답변 (1개)

Walter Roberson
Walter Roberson 2011년 7월 19일
You can use 1:52 for the xdata and then tell MATLAB to set the xlabels to the ones you want.
You can use two distinct axes side-by-side.
I was about to suggest datetick() but I see that it does not have a format for week number; ah well.
  댓글 수: 2
Michael
Michael 2011년 7월 19일
I tried using a multiline array in the xlabel function, but it won't list the numbers properly
Walter Roberson
Walter Roberson 2011년 7월 19일
Use a cell string.
set(gca, 'XTick', 1:52, 'XTickLabel', [cellstr(num2str((28:52).')); cellstr(num2str((1:27).'))])

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

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by