Effacer les filtres
Effacer les filtres

How to make weekdays axis?

3 vues (au cours des 30 derniers jours)
Aleksandra Pawlak
Aleksandra Pawlak le 26 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';

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Nov 2020
ax2.XAxis.TickLabelFormat = 'eee'; %or 'eeee'
  1 commentaire
Aleksandra Pawlak
Aleksandra Pawlak le 28 Nov 2020
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Language Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by