plotting dates on x axis with labels auto generated for 1st Jan each year?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm plotting monthly data (generally the 16th of the month) over 20 or more years with the dates held as datenum's.
I'm generating my plots in code.
Does anyone know if there's a way to force/tell matlab to just have yearly points on the x axis, ie datetick('x',24,'keepticks'))
BUT have these autogenerated to the beginning of each year? So while the label will read say "2007", that point will be "01/01/2007".
Thanks for any help,
Tom.
0 Kommentare
Antworten (2)
Andrei Bobrov
am 8 Dez. 2011
EDIT (0:20 MDT 09.12.2011)
input data (e.g.):
n = 22*12-7;
datedata = datenum(bsxfun(@plus,[1990 12 16],[zeros(n,1) (0:n-1)' zeros(n,1)]));
solution:
n2 = diff(year(dte([1,end])));
x = datenum(bsxfun(@plus,[1991 1 1],[(0:n2-1)' zeros(n2,2)]));
plot(datedata,rand(numel(datedata),1));grid on
set(gca,'XTick',x);
datetick('x','yyyy','keepticks')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Time Series Objects finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!