I am trying to plot a bunch of data that are 2 min averages and I want to have the label on the xaxis show day/month hour:mins. I can get some dates to show up on the xaxis but there are a few problems:
- location of xticks does not coincide with my data (see code snippet)
- in my real data i have +1000 points so i would like to label in certain time intervals, say every 12hrs.
below is a sample.
any help would be greatly welcome.
%make date vec
ds = {'28/01/2000 11:52:00';'28/01/2000 11:54:00';'28/01/2000 11:56:00'};
x = datenum(ds,'dd/mm/yyyy HH:MM:SS')
y = [1,2,3]; %data
plot (x,y,'x')
%define start and end date for xAxis
startDate = x(1)
endDate = x(end)
xdata = linspace(startDate,endDate,5)
set(gca,'XTick',xdata)
datetick('x','dd/yy HH:MM')
Add the option
keepticksto thedatetickcall. Fixed things up here on my R2012a:Source: this and datetick doc