datetick
Date formatted tick labels.
📝Syntax
datetick()
datetick(tickaxis)
datetick(tickaxis, dateFormat)
datetick(..., 'keeplimits')
datetick(..., 'keepticks')
datetick(ax, ...)
📥Input Arguments
Parameter Description
tickaxis Axis to label: 'x' (default), 'y' or 'z'.
dateFormat Date format, given as a datestr format string (for example 'yyyy') or format number.
'keeplimits' Keep the current axis limits.
'keepticks' Keep the current tick locations.
ax Target axes. Default is the current axes.
📄Description

datetick labels the ticks of an axis using dates, treating the tick values as serial date numbers (see datenum).

When no format is given, a format is chosen from the range spanned by the ticks. Use keepticks to preserve the current tick locations and keeplimits to preserve the current limits.

💡Examples
Label the x-axis with years.
t = datenum(2000, 1, 1):365:datenum(2010, 1, 1);
plot(t, rand(1, numel(t)));
datetick('x', 'yyyy');
🔗See Also
xticksxticklabelsxtickformat
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub