Intelligent Dynamic Date Ticks
Note de l’éditeur : 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')
Citation pour cette source
Ameya Deoras (2024). Intelligent Dynamic Date Ticks (https://www.mathworks.com/matlabcentral/fileexchange/27075-intelligent-dynamic-date-ticks), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
- MATLAB > Graphics > Formatting and Annotation > Axes Appearance > Limits, Ticks, and Grids > Grid Lines, Tick Values, and Labels >
Tags
Remerciements
A inspiré : 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
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
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 |