Intelligent Dynamic Date Ticks

版本 1.5.0.1 (4.9 KB) 作者: Ameya Deoras
Create plots with date-friendly data cursors and smart date ticks that scale with zooming & panning.
9.4K 次下载
更新时间 2016/9/1

查看许可证

编者注: This file was selected as MATLAB Central Pick of the Week

** 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.

USAGE:

dynamicDateTicks()
makes the current axes a date axes with dynamic properties

dynamicDateTicks(axH)
makes all the axes handles in vector axH dynamic date axes

dynamicDateTicks(axH, 'linked')
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.

EXAMPLES:
load integersignal
dates = datenum('July 1, 2008'):1/24:datenum('May 11, 2009 1:00 PM');
subplot(2,1,1), plot(dates, Signal1);
dynamicDateTicks
subplot(2,1,2), plot(dates, Signal4);
dynamicDateTicks([], [], 'dd/mm');

figure
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 (2024). Intelligent Dynamic Date Ticks (https://www.mathworks.com/matlabcentral/fileexchange/27075-intelligent-dynamic-date-ticks), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2010a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.5.0.1

Updated license

1.5.0.0

Added a function setDateAxes to set properties of an axes with dates and update tick labels automatically

1.4.0.0

DynamicDateTicks now supports an arbitrary day/month date formats. Use the third input argument to specify this: dynamicDateTicks([], [], 'dd/mm');

1.0.0.0