How to make weekdays axis?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!