I want to have ticks and labels (yyyy) on the horizontal axis that correspond to the turn of a year e.g. for 2000, the MATLAB serial code is 730486. I only want to have a tick for every second year. I have converted the data set into monthly frequency from December 1993 to July 2012 where I use last value available in very month, sometimes not necessarily the last calendar day (due to weekends, bank holidays, etc. - data availability) e.g. 29/07/2011. My (time-series) y variables are only available for these dates. I have been plotting these against the time they were measured so as to get an approximately accurate graph. Is there any way of having the x axis tick exactly at the turn of the year and once only every two years?
So far I tried:
hold on v=datestr(exceldata(:,1)+693960,'dd/mm/yyyy') n=datenum(v,'dd/mm/yyyy') plot(n,exceldata(:,2)) xtic=[1994:2:2012]; set(gca,'XTick',xtic); datetick('x','yyyy','keeplimits','keepticks');
but it does not produce any labels or ticks on the time/horizontal axis since my dates do not include the values 1994:2:2012.
No products are associated with this question.
Yes. See documentation on
XTick vector of data values locating tick marks XTickLabel ... strings to use as labels for tick marks ...
datetick might be smarter than I think, i.e. it takes care of XTickLabel. However your xtic must take values in the interval defined by your n; "data values" refers to your n.