View License

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

» Watch video

Highlights from
datefig: figure handle class with automatically readjusting date ticks

5.0 | 2 ratings Rate this file 3 Downloads (last 30 days) File Size: 2.45 KB File ID: #32359 Version: 1.1
image thumbnail

datefig: figure handle class with automatically readjusting date ticks


Mark Mikofski (view profile)


27 Jul 2011 (Updated )

Handle class object that automatically resets date ticks after resize, zoom or pan.

| Watch this File

File Information

The MATLAB command datetick('x') will not automatically update date ticks if a figure is resized, zoomed or panned. datefig is a class definition that creates a MATLAB figure with ResizeFcn, zoom and pan callbacks that call datetick('x','keeplimits') for all axes with plots in a figure.

It can work with any plotting function, but will not show the date ticks until the figure is resized or the axes are zoomed/panned the first time. I am sure there is an axes-creation callback, but I could not find it easily. I will try to add it in a future version. Since it uses the MATLAB function datetick, it will not make sense unless the abscissa is a MATLAB serial date number.

There are overloaded plot, scatter and plotyy functions that put date ticks on the x-axis. If a datefig class object if specified as the first object, then it will plot in that figure, otherwise it will create a datefig object. The datefig class object is an optional second output. The overloaded methods are similar to the MATLAB functions. However, I'm not sure what it will do with AX as an argument. Also if the xdata is not a MATLAB serial date number then it will probably output garbage on the x-axis.

h = datefig;

This is more generic alternate to using the MATLAB builtin timeseries class.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
08 May 2015 Ingeniero_Andres

This is really good. It works for my project, specially for plotyy. I have to test all functions. Thanks

17 Oct 2013 Zoe

Zoe (view profile)

love love love.. i use this daily.. beautiful plots.. and i like that the axis zoom.. and reconfigure :D

29 Jul 2011 1.1

fix plot inputs, add overloaded method for scatter, add overloaded method for plotyy, fix errors with zoom/pan

Contact us