dateaxis
Convert serial-date axis labels to calendar-date axis labels
Description
Examples
Replace Axis Tick Labels with Date Labels
This example shows how to use dateaxis to replaces axis tick labels with date labels on a graphic figure.
Convert the x-axis labels to an automatically determined date format.
dateaxis('y', 6)
Convert the y-axis labels to the month/day format.
dateaxis('x', 2, datetime(1999,3,3))
Convert the x-axis labels to the month/day/year format. The minimum x-tick value is treated as March 3, 1999.
dateaxis('x', 2, datetime(1999,3,3))
Input Arguments
Tickaxis
— Determines which axis tick labels, x
, y
, z
to replace
'x'
(default) | character vector with value 'x'
,
'y'
, or 'z'
(Optional) Determines which axis tick labels —x, y, or z— to replace, specified as a character vector.
Data Types: char
DateForm
— Defines which date format to use
date format based on the span of the axis limits (default) | integer from 0
to 17
(Optional) Defines which date format to use, specified as an integer from
0
to 17
.
If no DateForm
argument is entered, this function
determines the date format based on the span of the axis limits. For
example, if the difference between the axis minimum and maximum is less than
15, the tick labels are converted to three-letter day-of-the-week
abbreviations (DateForm = 8
).
| Format | Description |
---|---|---|
|
| day-month-year hour:minute:second |
|
| day-month-year |
|
| month/day/year |
|
| month, three letters |
|
| month, single letter |
|
| month |
|
| month/day |
|
| day of month |
|
| day of week, three letters |
|
| day of week, single letter |
|
| year, four digits |
|
| year, two digits |
|
| month year |
|
| hour:minute:second |
|
| hour:minute:second AM or PM |
|
| hour:minute |
|
| hour:minute AM or PM |
|
| year month day |
Refer to the MATLAB®
set
command for
information on modifying the axis tick values and other axis parameters.
Data Types: double
StartDate
— Assigns the date to the first axis tick value
lower axis limit converted to the appropriate date
number (default) | datetime scalar | string scalar | date character vector
(Optional) Assigns the date to the first axis tick value, specified as a scalar datetime, string, or date character vector.
The default StartDate
is the lower axis limit converted
to the appropriate date number. For example, a tick value of
1
is converted to the date 01-Jan-0000. Entering
StartDate
as '06-apr-1999'
assigns
the date April 6, 1999 to the first tick value and the axis tick labels are
set accordingly.
To support existing code, dateaxis
also
accepts serial date numbers as inputs, but they are not recommended.
Data Types: char
| string
| datetime
Version History
Introduced before R2006aR2022b: Serial date numbers not recommended
Although dateaxis
supports serial date numbers,
datetime
values are recommended instead. The
datetime
data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime
values, use the datetime
function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)