MATLAB: Date on X-axis when zooming the plot

datetick

I've plotted a file with 120,000 points. The x data is a time with a format 'MM/DD/YYYY HH:MM:SS' (10/30/2010 11:16:00 PM. I have successfully plotted it (though it took me 62 seconds to do it). My problem is when i zoom the plot, the datetick (x-axis) does automatically zooms in. In the whole plot, i only have 6 x-ticks, and when i zoom it in, the x-ticks is still the same. I've used datetick('x', 'mm/dd/yy HH:MM:SS', 'keepticks').

Best Answer

You could try this submission : Intelligent Dynamic Date Ticks
DYNAMICDATETICKS is a wrapper function around DATETICK which creates dynamic date tick labels for plots with dates on the X-axis. The date ticks intelligently include year/month/day information on specific ticks as appropriate. The ticks are dynamic with respect to zooming and panning. They update as the timescale changes (from years to seconds). Data tips on the plot also show intelligently as dates.