How to make weekdays axis?

조회 수: 6 (최근 30일)
Aleksandra Pawlak
Aleksandra Pawlak 2020년 11월 26일
댓글: Aleksandra Pawlak 2020년 11월 28일
Hi,
I want to change dates on the chart to the weekdays (names-monday etc. -not day 1st).
This is my code:
figure(1)
ax1 = axes();
ax1.Box = 'on';
y=[2.2 2.2]
area([0 59],y, 'FaceColor', [0.9 0.9 0.9],'LineStyle','none');
hold on
area([203 347],y, 'FaceColor', [0.9 0.9 0.9],'LineStyle','none');
hold on
area([491 635],y, 'FaceColor', [0.9 0.9 0.9],'LineStyle','none');
hold on
area([779 923],y, 'FaceColor', [0.9 0.9 0.9],'LineStyle','none');
hold on
f=plot(x, THDUmeanL1, x, THDUmeanL2, x, THDUmeanL3)
%legend('04.04.2001','06.04.2001','08.04.2001','10.04.2001')
ax=gca
xticks([1 24:24:1008])
xticklabels({'14:20','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00','18:00','22:00','02:00','06:00','10:00','14:00'})
xtickangle(-60)
xlim([1,1008])
ylim([0,2.2])
ax2 = axes();
hold(ax2);
ax2.Position = ax1.Position;
ax2.Color = 'none';
ax2.XAxisLocation = 'top';
ax2.YAxis.Visible = 'off';
plot(NaT, NaN); % to make x-axis datetime
ax2.XLim = [datetime(2001, 3, 28) datetime(2001, 4, 4)]+hours(8);
ax2.XTick = [ax2.XLim(1) ax2.XTick];
drawnow;
ax2.XAxis.TickLabelFormat = 'MMM dd';

채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 27일
ax2.XAxis.TickLabelFormat = 'eee'; %or 'eeee'

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by