The LABEL_DATE function can be used, in conjunction with the [XYZ]TICKFORMAT keyword to IDL plotting routines, to easily label axes with dates and times.
This routine is written in the IDL language. Its source code can be found in the file label_date.pro in the lib subdirectory of the IDL distribution.
Result = LABEL_DATE( [DATE_FORMAT=string/string array]
[, AM_PM=2-element vector of strings]
[, DAYS_OF_WEEK=7-element vector of strings]
[, MONTHS=12-element vector of strings] [, OFFSET=value] [, /ROUND_UP] )
and then,
PLOT, x, y, XTICKFORMAT = 'LABEL_DATE'
Returns a date formatting definition.
If LABEL_DATE is being called to initialize string formats, it should be called with no arguments and the DATE_FORMAT keyword should be set.
| Note |
Set this keyword to a two-element string array that contains the names to be used with '%A'. The default is ['am','pm'].
Set this keyword to a format string or array of format strings. Each string corresponds to an axis level as provided by the [XYZ]TICKUNITS keyword to the plotting routine. If there are fewer strings than axis levels, then the strings are cyclically repeated. A string can contain any of the following codes:
Other items you can include can consist of:
If DATE_FORMAT is not specified then the default is the standard 24-character system format, '%W %M %D %H:%I:%S %Y'.
The following table contains some examples of DATE_FORMAT strings and the resulting output:
Set this keyword to a seven-element string array that contains the names to be used with '%W'. The default is the three-letter English abbreviations, ['Sun, 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].
Set this keyword to a twelve-element string array that contains the names to be used with '%M'. The default is the three-letter English abbreviations, ['Jan', 'Feb',..., 'Dec'].
Set this keyword to a value representing the offset to be added to each tick value before conversion to a label. This keyword is usually used when your axis values are measured relative to a certain starting time. In this case, OFFSET should be set to the Julian date of the starting time.
Set this keyword to force times to be rounded up to the nearest minute after the 30 second mark in the DATE_FORMAT string. The default is for times to be truncated to the smallest time unit.
| Note |
This example creates a sample plot that has a date axis from Jan 1 to June 30, 2000:
; Create format strings for a two-level axis: dummy = LABEL_DATE(DATE_FORMAT=['%D-%M','%Y']) ;Generate the Date/Time data time = TIMEGEN(START=JULDAY(1,1,2000), FINAL=JULDAY(6,30,2000)) ;Generate the Y-axis data data = RANDOMN(seed, N_ELEMENTS(time)) ;Plot the data PLOT, time, data, XTICKUNITS = ['Time', 'Time'], $ XTICKFORMAT='LABEL_DATE', XSTYLE=1, XTICKS=6, YMARGIN=[6,2]
For more examples, see [XYZ]TICKFORMAT.
Introduced: Pre 4.0
[XYZ]TICKFORMAT, CALDAT, JULDAY, SYSTIME, TIMEGEN, Format Codes