필터 지우기
필터 지우기

Change the x axis labels in plot.

조회 수: 4 (최근 30일)
Manuel S Mathew
Manuel S Mathew 2020년 10월 31일
댓글: Ameer Hamza 2020년 11월 1일
I have a dataset of hourly production throughout a year. So that is 8760 data points. I would like to plot all these 8760 points. But, I just want to label months. So, what I would like to do is to label the x-axis January, February, ... , December instead of what I have now, which is 1,2,3, ..., 8760. Any help is highly appreciated.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 10월 31일
This code shows an example
x = rand(1, 8760); % your vector
t = datetime(2019,1,1,0,0,0):hours(1):datetime(2019,12,31,23,0,0); % 2019 is used because 2020 is leap year
ax = axes();
hold(ax);
plot(t, x)
ax.XTickLabelMode = 'manual';
ax.XTick = datetime(2019,1,1,0,0,0):calmonths(1):datetime(2019,12,31,23,0,0);
ax.XTickLabel = datestr(ax.XTick,'mmm');
  댓글 수: 2
Manuel S Mathew
Manuel S Mathew 2020년 11월 1일
Thank you so much. This solved it.
Ameer Hamza
Ameer Hamza 2020년 11월 1일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by