** Update: The archive now includes a new function setDateAxes which can be used like SET to set the properties of date axes (such as XLim) and have the tick labels update automatically. For example,
setDateAxes(gca, 'XLim', [datenum('July 1, 2008') datenum('August 1, 2008')])
** Update: DynamicDateTicks now supports an arbitrary day/month date formats. Use the third input argument to specify this: dynamicDateTicks(, , 'dd/mm');
DYNAMICDATETICKS is a wrapper function around DATETICK which creates dynamic date tick labels for plots with dates on the X-axis. Features include:
* Smart ticks: Include year/month/day information on specific ticks as appropriate.
* Dynamic ticks: Ticks update as the plot is panned or zoomed
* Scaling ticks: Ticks change format as the timescale changes (from years to seconds).
* Support for multiple axes: Supports any combination of date and non-date axes as well as linked axes
* Date-friendly data tips: Dates displayed correctly on data cursors.
makes the current axes a date axes with dynamic properties
makes all the axes handles in vector axH dynamic date axes
additionally specifies that all the axes in axH are linked. This
option should be used in conjunction with LINKAXES.
dynamicDateTicks(axH, 'link', 'dd/mm')
additionally specifies the format of all ticks that include both
date and month information. The default value is 'mm/dd' but
any valid date string format can be specified. The first two
options may be empty  if only specifying format.
dates = datenum('July 1, 2008'):1/24:datenum('May 11, 2009 1:00 PM');
subplot(2,1,1), plot(dates, Signal1);
subplot(2,1,2), plot(dates, Signal4);
dynamicDateTicks(, , 'dd/mm');
ax1 = subplot(2,1,1); plot(dates, Signal1);
ax2 = subplot(2,1,2); plot(dates, Signal4);
linkaxes([ax1 ax2], 'x');
dynamicDateTicks([ax1 ax2], 'linked')
Ameya Deoras (2021). Intelligent Dynamic Date Ticks (https://www.mathworks.com/matlabcentral/fileexchange/27075-intelligent-dynamic-date-ticks), MATLAB Central File Exchange. Retrieved .
Inspired: cbdate, MATLAB for R Users in Computational Finance, XivelyRead, Energy Trading & Risk Management with MATLAB Webinar Case Study, Electricity Load and Price Forecasting Webinar Case Study, Commodities Trading with MATLAB
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!