How to make weekdays axis?
4 views (last 30 days)
Show older comments
Aleksandra Pawlak
on 26 Nov 2020
Commented: Aleksandra Pawlak
on 28 Nov 2020
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';
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!