def frequency_ticks(locs, *args, **kwargs):  # pylint: disable=star-args

    n_ticks = kwargs.pop('n_ticks', 5)
    axis = kwargs.pop('axis', 'x')
    freq_fmt = kwargs.pop('freq_fmt', None)

    if axis == 'x':
        ticker = plt.xticks
    elif axis == 'y':
        ticker = plt.yticks
    else:
        raise ParameterError("axis must be either 'x' or 'y'.")

    if len(args) > 0:
        freqs = args[0]
    else:
        freqs = locs
        locs = np.arange(len(freqs))

    if n_ticks is not None:
        # Slice the locations and labels evenly between 0 and the last point
        positions = np.linspace(0, len(locs)-1, n_ticks,
                                endpoint=True).astype(int)
        locs = locs[positions]
        freqs = freqs[positions]

    # Format the labels by time
    formats = {'mHz': lambda f: '{:.5g}'.format(f * 1e3),
               'Hz': '{:.5g}'.format,
               'kHz': lambda f: '{:.5g}'.format(f * 1e-3),
               'MHz': lambda f: '{:.5g}'.format(f * 1e-6),
               'GHz': lambda f: '{:.5g}'.format(f * 1e-9)}

    f_max = np.max(freqs)

    if freq_fmt is None:
        if f_max > 1e10:
            freq_fmt = 'GHz'
        elif f_max > 1e7:
            freq_fmt = 'MHz'
        elif f_max > 1e4:
            freq_fmt = 'kHz'
        elif f_max > 1e1:
            freq_fmt = 'Hz'
        else:
            freq_fmt = 'mHz'

    elif freq_fmt not in formats:
        raise ParameterError('Invalid format: {:s}'.format(freq_fmt))

    ticks = [formats[freq_fmt](f) for f in freqs]

    return ticker(locs, ticks, **kwargs), freq_fmt
Plot frequency-formatted axis ticks.
dataset/ETHPy150Open bmcfee/librosa/librosa/display.py/frequency_ticks