librosa/display.py
def __decorate_axis(axis, ax_type):
    '''Configure axis tickers, locators, and labels'''

    if ax_type == 'tonnetz':
        axis.set_major_formatter(TonnetzFormatter())
        axis.set_major_locator(FixedLocator(0.5 + np.arange(6)))
        axis.set_label_text('Tonnetz')

    elif ax_type == 'chroma':
        axis.set_major_formatter(ChromaFormatter())
        axis.set_major_locator(FixedLocator(0.5 +
                                            np.add.outer(12 * np.arange(10),
                                                         [0, 2, 4, 5, 7, 9, 11]).ravel()))
        axis.set_label_text('Pitch class')

    elif ax_type == 'tempo':
        axis.set_major_formatter(ScalarFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_label_text('BPM')

    elif ax_type == 'time':
        axis.set_major_formatter(TimeFormatter(unit=None, lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time')

    elif ax_type == 's':
        axis.set_major_formatter(TimeFormatter(unit='s', lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time (s)')

    elif ax_type == 'ms':
        axis.set_major_formatter(TimeFormatter(unit='ms', lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time (ms)')

    elif ax_type == 'lag':
        axis.set_major_formatter(TimeFormatter(unit=None, lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag')

    elif ax_type == 'lag_s':
        axis.set_major_formatter(TimeFormatter(unit='s', lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag (s)')

    elif ax_type == 'lag_ms':
        axis.set_major_formatter(TimeFormatter(unit='ms', lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag (ms)')

    elif ax_type == 'cqt_note':
        axis.set_major_formatter(NoteFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_minor_formatter(NoteFormatter(major=False))
        axis.set_minor_locator(LogLocator(base=2.0,
                                          subs=2.0**(np.arange(1, 12)/12.0)))
        axis.set_label_text('Note')

    elif ax_type in ['cqt_hz']:
        axis.set_major_formatter(LogHzFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_minor_formatter(LogHzFormatter(major=False))
        axis.set_minor_locator(LogLocator(base=2.0,
                                          subs=2.0**(np.arange(1, 12)/12.0)))
        axis.set_label_text('Hz')

    elif ax_type in ['mel', 'log']:
        axis.set_major_formatter(ScalarFormatter())
        axis.set_major_locator(SymmetricalLogLocator(axis.get_transform()))
        axis.set_label_text('Hz')

    elif ax_type in ['linear', 'hz']:
        axis.set_major_formatter(ScalarFormatter())
        axis.set_label_text('Hz')

    elif ax_type in ['frames']:
        axis.set_label_text('Frames')

    elif ax_type in ['off', 'none', None]:
        axis.set_label_text('')
        axis.set_ticks([])
def __decorate_axis(axis, ax_type):
    '''Configure axis tickers, locators, and labels'''

    if ax_type == 'tonnetz':
        axis.set_major_formatter(TonnetzFormatter())
        axis.set_major_locator(FixedLocator(0.5 + np.arange(6)))
        axis.set_label_text('Tonnetz')

    elif ax_type == 'chroma':
        axis.set_major_formatter(ChromaFormatter())
        axis.set_major_locator(FixedLocator(0.5 +
                                            np.add.outer(12 * np.arange(10),
                                                         [0, 2, 4, 5, 7, 9, 11]).ravel()))
        axis.set_label_text('Pitch class')

    elif ax_type == 'tempo':
        axis.set_major_formatter(ScalarFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_label_text('BPM')

    elif ax_type == 'time':
        axis.set_major_formatter(TimeFormatter(unit=None, lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time')

    elif ax_type == 's':
        axis.set_major_formatter(TimeFormatter(unit='s', lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time (s)')

    elif ax_type == 'ms':
        axis.set_major_formatter(TimeFormatter(unit='ms', lag=False))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Time (ms)')

    elif ax_type == 'lag':
        axis.set_major_formatter(TimeFormatter(unit=None, lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag')

    elif ax_type == 'lag_s':
        axis.set_major_formatter(TimeFormatter(unit='s', lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag (s)')

    elif ax_type == 'lag_ms':
        axis.set_major_formatter(TimeFormatter(unit='ms', lag=True))
        axis.set_major_locator(MaxNLocator(prune=None,
                                           steps=[1, 1.5, 5, 6, 10]))
        axis.set_label_text('Lag (ms)')

    elif ax_type == 'cqt_note':
        axis.set_major_formatter(NoteFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_minor_formatter(NoteFormatter(major=False))
        axis.set_minor_locator(LogLocator(base=2.0,
                                          subs=2.0**(np.arange(1, 12)/12.0)))
        axis.set_label_text('Note')

    elif ax_type in ['cqt_hz']:
        axis.set_major_formatter(LogHzFormatter())
        axis.set_major_locator(LogLocator(base=2.0))
        axis.set_minor_formatter(LogHzFormatter(major=False))
        axis.set_minor_locator(LogLocator(base=2.0,
                                          subs=2.0**(np.arange(1, 12)/12.0)))
        axis.set_label_text('Hz')

    elif ax_type in ['mel', 'log']:
        axis.set_major_formatter(ScalarFormatter())
        axis.set_major_locator(SymmetricalLogLocator(axis.get_transform()))
        axis.set_label_text('Hz')

    elif ax_type in ['linear', 'hz']:
        axis.set_major_formatter(ScalarFormatter())
        axis.set_label_text('Hz')

    elif ax_type in ['frames']:
        axis.set_label_text('Frames')

    elif ax_type in ['off', 'none', None]:
        axis.set_label_text('')
        axis.set_ticks([])
def __decorate_axis ( axis , ax_type ) : if ax_type == 'tonnetz' : axis . set_major_formatter ( TonnetzFormatter ( ) ) axis . set_major_locator ( FixedLocator ( 0.5 + np . arange ( 6 ) ) ) axis . set_label_text ( 'Tonnetz' ) elif ax_type == 'chroma' : axis . set_major_formatter ( ChromaFormatter ( ) ) axis . set_major_locator ( FixedLocator ( 0.5 + np . add . outer ( 12 * np . arange ( 10 ) , [ 0 , 2 , 4 , 5 , 7 , 9 , 11 ] ) . ravel ( ) ) ) axis . set_label_text ( 'Pitch class' ) elif ax_type == 'tempo' : axis . set_major_formatter ( ScalarFormatter ( ) ) axis . set_major_locator ( LogLocator ( base = 2.0 ) ) axis . set_label_text ( 'BPM' ) elif ax_type == 'time' : axis . set_major_formatter ( TimeFormatter ( unit = None , lag = False ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Time' ) elif ax_type == 's' : axis . set_major_formatter ( TimeFormatter ( unit = 's' , lag = False ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Time (s)' ) elif ax_type == 'ms' : axis . set_major_formatter ( TimeFormatter ( unit = 'ms' , lag = False ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Time (ms)' ) elif ax_type == 'lag' : axis . set_major_formatter ( TimeFormatter ( unit = None , lag = True ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Lag' ) elif ax_type == 'lag_s' : axis . set_major_formatter ( TimeFormatter ( unit = 's' , lag = True ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Lag (s)' ) elif ax_type == 'lag_ms' : axis . set_major_formatter ( TimeFormatter ( unit = 'ms' , lag = True ) ) axis . set_major_locator ( MaxNLocator ( prune = None , steps = [ 1 , 1.5 , 5 , 6 , 10 ] ) ) axis . set_label_text ( 'Lag (ms)' ) elif ax_type == 'cqt_note' : axis . set_major_formatter ( NoteFormatter ( ) ) axis . set_major_locator ( LogLocator ( base = 2.0 ) ) axis . set_minor_formatter ( NoteFormatter ( major = False ) ) axis . set_minor_locator ( LogLocator ( base = 2.0 , subs = 2.0 ** ( np . arange ( 1 , 12 ) / 12.0 ) ) ) axis . set_label_text ( 'Note' ) elif ax_type in [ 'cqt_hz' ] : axis . set_major_formatter ( LogHzFormatter ( ) ) axis . set_major_locator ( LogLocator ( base = 2.0 ) ) axis . set_minor_formatter ( LogHzFormatter ( major = False ) ) axis . set_minor_locator ( LogLocator ( base = 2.0 , subs = 2.0 ** ( np . arange ( 1 , 12 ) / 12.0 ) ) ) axis . set_label_text ( 'Hz' ) elif ax_type in [ 'mel' , 'log' ] : axis . set_major_formatter ( ScalarFormatter ( ) ) axis . set_major_locator ( SymmetricalLogLocator ( axis . get_transform ( ) ) ) axis . set_label_text ( 'Hz' ) elif ax_type in [ 'linear' , 'hz' ] : axis . set_major_formatter ( ScalarFormatter ( ) ) axis . set_label_text ( 'Hz' ) elif ax_type in [ 'frames' ] : axis . set_label_text ( 'Frames' ) elif ax_type in [ 'off' , 'none' , None ] : axis . set_label_text ( '' ) axis . set_ticks ( [ ] )
Configure axis tickers, locators, and labels
Configure axis tickers locators and labels