librosa.display.time_ticks

librosa.display.time_ticks(locs, *args, **kwargs)[source]

Plot time-formatted axis ticks.

Parameters:

locations : list or np.ndarray

Time-stamps for tick marks

n_ticks : int > 0 or None

Show this number of ticks (evenly spaced).

If none, all ticks are displayed.

Default: 5

axis : ‘x’ or ‘y’

Which axis should the ticks be plotted on? Default: ‘x’

time_fmt : None or {‘ms’, ‘s’, ‘m’, ‘h’}

  • ‘ms’: milliseconds (eg, 241ms)
  • ‘s’: seconds (eg, 1.43s)
  • ‘m’: minutes (eg, 1:02)
  • ‘h’: hours (eg, 1:02:03)

If none, formatted is automatically selected by the range of the times data.

Default: None

fmt : str

Warning

This parameter name was in librosa 0.4.2 Use the time_fmt parameter instead. The fmt parameter will be removed in librosa 0.5.0.

kwargs : additional keyword arguments.

See matplotlib.pyplot.xticks or yticks for details.

Returns:

locs

labels

Locations and labels of tick marks

See also

matplotlib.pyplot.xticks, matplotlib.pyplot.yticks

Examples

>>> # Tick at pre-computed beat times
>>> librosa.display.specshow(S)
>>> librosa.display.time_ticks(beat_times)
>>> # Set the locations of the time stamps
>>> librosa.display.time_ticks(locations, timestamps)
>>> # Format in seconds
>>> librosa.display.time_ticks(beat_times, time_fmt='s')
>>> # Tick along the y axis
>>> librosa.display.time_ticks(beat_times, axis='y')