Time format printing too much

2 visualizzazioni (ultimi 30 giorni)
black
black il 21 Set 2019
Commentato: black il 22 Set 2019
I want to label the time axis in a plot with "ddd: HH" (speak "first three letters of the day, then the two digits for the hour in 24-hour format).
However, when doing this, the format is applied for some labels, but otheres also print more information like month, day and year.
% generate time sequence, last 3 days, 12 hours offset
xtickformat('eee: HH')
t2 = datetime('today'),
t1 = t2-days(3)
xData = t1:hours(12):t2
set(gca,'xtick',xData)
Leads to:
Screenshot 2019-09-21 at 10.00.55.png

Risposta accettata

dpb
dpb il 21 Set 2019
Modificato: dpb il 21 Set 2019
I presume your complaint is the range label automagically shown for datetime axes. Seems there should be a way for user to turn that on/off, but doesn't appear to be...
The following generates
t2 = datetime('today');
t1 = t2-days(3);
xData = t1:hours(12):t2;
hL=plot(xData,randn(size(xData)));
xticks(xData)
xtickformat('eee: HH')
hAx=gca; % get current axes handle
hXAx=hAx.XAxis; % retrieve handle to xaxis datetime ruler object
hXAx.SecondaryLabel.String=''; % set the limits label string to empty
The SecondaryLabel property is hidden one -- used the FEX submission of Yair Altman to discover the name of the nondisclosed properties.
NB: Until the axes is created as a datetime ruler object, xtickformat will fail as will xticks as default requires double. At least thru R2017b here--perhaps later releases will automagically convert the axis type as needed; can't test that here but I'd be somewhat surprised.

Più risposte (0)

Community

Più risposte nel  ThingSpeak Community

Categorie

Scopri di più su Visualize Data in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by