librosa.display.NoteFormatter

class librosa.display.NoteFormatter(octave=True, major=True)[source]

Ticker formatter for Notes

Parameters:
octave : bool

If True, display the octave number along with the note name.

Otherwise, only show the note name (and cent deviation)

major : bool

If True, ticks are always labeled.

If False, ticks are only labeled if the span is less than 2 octaves

Examples

>>> import matplotlib.pyplot as plt
>>> values = librosa.midi_to_hz(np.arange(48, 72))
>>> plt.figure()
>>> ax1 = plt.subplot(2,1,1)
>>> ax1.bar(np.arange(len(values)), values)
>>> ax1.set_ylabel('Hz')
>>> ax2 = plt.subplot(2,1,2)
>>> ax2.bar(np.arange(len(values)), values)
>>> ax2.yaxis.set_major_formatter(librosa.display.NoteFormatter())
>>> ax2.set_ylabel('Note')

(Source code)

../_images/librosa-display-NoteFormatter-1.png
__init__(octave=True, major=True)[source]