View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Zoom Adaptive Date Ticks

4.8 | 10 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.6 KB File ID: #15342 Version:

Zoom Adaptive Date Ticks



18 Jun 2007 (Updated )

Make date ticks adapt to zooming

Editor's Notes:

This was a File Exchange Pick of the Week

| Watch this File

File Information

Note that although this piece of code still works with R2014b, the same effect can be achieved by simply using the new datetime data type as first input to plot when running R2014b or newer versions.
% zoomAdaptiveDateTicks('on')
% Turns on the automatic adaptation of date ticks
% to user zooming for the current figure window
% zoomAdaptiveDateTicks('off')
% Turns off the automatic adaptation of date ticks
% to user zooming for the current figure window
% zoomAdaptiveDateTicks('demo')
% Opens a demo figure window to play with


This file inspired Cbdate.

Required Products MATLAB
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
18 Aug 2014 Rafal Czarny

06 Feb 2014 Diego

Diego (view profile)

27 Sep 2011 lflorhid

Very, very useful.. thank you very much

13 Jun 2011 Stijn de Waele

Useful script! For multiple axes with linked time axis, I have modified the code to:
function adaptiveDateTicks(figureHandle,eventObjectHandle)
% Resetting x axis to automatic tick mark generation
arrayfun(@(x) set(x,'XTickMode','auto'),ax)
% using automaticallly generate date ticks
arrayfun(@(x) datetick(x,'x','keeplimits'),ax)

04 Apr 2011 Ryan Moffet

26 Jul 2010 Hans Martin Aannestad

Thank you so much for this! I have struggled with 'manual mode' and updating date vectors for ages, this is such a simple and elegant solution.

02 Aug 2007 Richard Stephens

This is just what I've been looking for!

11 Jul 2007 Jeremy Almeter

This function is very useful. It is short, simple, and makes the graphs easier to read.

07 Jul 2007 Les Beckham

This is nice and should prove useful.

The 'demo' feature uses the 'today' function which, apparently, only ships with the Financial toolbox. If you replace the line
dates = today - linspace(1169,0,15000)';
dates = floor(now) - linspace(1169,0,15000)';

it will work without the 'today' function.

20 Jun 2007 Erik Stalberg

Thanks Andreas! This tool is very useful and the code is very well written.
Erik Stalberg

03 Oct 2014 1.1

Note for the new R2014b release.

01 Sep 2016

Updated license

Contact us