librosa.display.LogHzFormatter

class librosa.display.LogHzFormatter(major=True)[source]

Ticker formatter for logarithmic frequency

Parameters:
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.yaxis.set_major_formatter(librosa.display.LogHzFormatter())
>>> 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-LogHzFormatter-1.png
__init__(major=True)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([major]) Initialize self.
create_dummy_axis(**kwargs)
fix_minus(s) Some classes may want to replace a hyphen for minus with the proper unicode symbol (U+2212) for typographical correctness.
format_data(value) Returns the full string representation of the value with the position unspecified.
format_data_short(value) Return a short string version of the tick value.
get_offset()
set_axis(axis)
set_bounds(vmin, vmax)
set_data_interval(vmin, vmax)
set_locs(locs)
set_view_interval(vmin, vmax)

Attributes

axis
locs