def plot_ideal_filter(freq, gain, axes=None, title='', flim=None, fscale='log', alim=_DEFAULT_ALIM, color='r', alpha=0.5, linestyle='--', show=True):
    'Plot an ideal filter response.\n\n    Parameters\n    ----------\n    freq : array-like\n        The ideal response frequencies to plot (must be in ascending order).\n    gain : array-like or None\n        The ideal response gains to plot.\n    axes : instance of Axes | None\n        The subplot handle. With None (default), axes are created.\n    title : str\n        The title to use, (default: \'\').\n    flim : tuple or None\n        If not None, the x-axis frequency limits (Hz) to use.\n        If None (default), freq used.\n    fscale : str\n        Frequency scaling to use, can be "log" (default) or "linear".\n    alim : tuple\n        If not None (default), the y-axis limits (dB) to use.\n    color : color object\n        The color to use (default: \'r\').\n    alpha : float\n        The alpha to use (default: 0.5).\n    linestyle : str\n        The line style to use (default: \'--\').\n    show : bool\n        Show figure if True (default).\n\n    Returns\n    -------\n    fig : instance of matplotlib.figure.Figure\n        The figure.\n\n    See Also\n    --------\n    plot_filter\n\n    Notes\n    -----\n    .. versionadded:: 0.14\n\n    Examples\n    --------\n    Plot a simple ideal band-pass filter::\n\n        >>> from mne.viz import plot_ideal_filter\n        >>> freq = [0, 1, 40, 50]\n        >>> gain = [0, 1, 1, 0]\n        >>> plot_ideal_filter(freq, gain, flim=(0.1, 100))  #doctest: +ELLIPSIS\n        <...Figure...>\n    '
    import matplotlib.pyplot as plt
    (my_freq, my_gain) = (list(), list())
    if (freq[0] != 0):
        raise ValueError(('freq should start with DC (zero) and end with Nyquist, but got %s for DC' % (freq[0],)))
    freq = np.array(freq)
    _check_option('fscale', fscale, ['log', 'linear'])
    if (fscale == 'log'):
        freq[0] = ((0.1 * freq[1]) if (flim is None) else min(flim[0], freq[1]))
    flim = _get_flim(flim, fscale, freq)
    transitions = list()
    for ii in range(len(freq)):
        if ((ii < (len(freq) - 1)) and (gain[ii] != gain[(ii + 1)])):
            transitions += [[freq[ii], freq[(ii + 1)]]]
            my_freq += np.linspace(freq[ii], freq[(ii + 1)], 20, endpoint=False).tolist()
            my_gain += np.linspace(gain[ii], gain[(ii + 1)], 20, endpoint=False).tolist()
        else:
            my_freq.append(freq[ii])
            my_gain.append(gain[ii])
    my_gain = (10 * np.log10(np.maximum(my_gain, (10 ** (alim[0] / 10.0)))))
    if (axes is None):
        axes = plt.subplots(1)[1]
    for transition in transitions:
        axes.axvspan(*transition, color=color, alpha=0.1)
    axes.plot(my_freq, my_gain, color=color, linestyle=linestyle, alpha=0.5, linewidth=4, zorder=3)
    (xticks, xticklabels) = _filter_ticks(flim, fscale)
    axes.set(ylim=alim, xlabel='Frequency (Hz)', ylabel='Amplitude (dB)', xscale=fscale)
    if (xticks is not None):
        axes.set(xticks=xticks)
        axes.set(xticklabels=xticklabels)
    axes.set(xlim=flim)
    if title:
        axes.set(title=title)
    adjust_axes(axes)
    tight_layout()
    plt_show(show)
    return axes.figure
Plot an ideal filter response.

Parameters
----------
freq : array-like
    The ideal response frequencies to plot (must be in ascending order).
gain : array-like or None
    The ideal response gains to plot.
axes : instance of Axes | None
    The subplot handle. With None (default), axes are created.
title : str
    The title to use, (default: '').
flim : tuple or None
    If not None, the x-axis frequency limits (Hz) to use.
    If None (default), freq used.
fscale : str
    Frequency scaling to use, can be "log" (default) or "linear".
alim : tuple
    If not None (default), the y-axis limits (dB) to use.
color : color object
    The color to use (default: 'r').
alpha : float
    The alpha to use (default: 0.5).
linestyle : str
    The line style to use (default: '--').
show : bool
    Show figure if True (default).

Returns
-------
fig : instance of matplotlib.figure.Figure
    The figure.

See Also
--------
plot_filter

Notes
-----
.. versionadded:: 0.14

Examples
--------
Plot a simple ideal band-pass filter::

    >>> from mne.viz import plot_ideal_filter
    >>> freq = [0, 1, 40, 50]
    >>> gain = [0, 1, 1, 0]
    >>> plot_ideal_filter(freq, gain, flim=(0.1, 100))  #doctest: +ELLIPSIS
    <...Figure...>
def plot_ideal_filter(freq, gain, axes=None, title=, flim=None, fscale='log', alim=_DEFAULT_ALIM, color='r', alpha=0.5, linestyle='--', show=True):
    'Plot an ideal filter response.\n\n    Parameters\n    ----------\n    freq : array-like\n        The ideal response frequencies to plot (must be in ascending order).\n    gain : array-like or None\n        The ideal response gains to plot.\n    axes : instance of Axes | None\n        The subplot handle. With None (default), axes are created.\n    title : str\n        The title to use, (default: \'\').\n    flim : tuple or None\n        If not None, the x-axis frequency limits (Hz) to use.\n        If None (default), freq used.\n    fscale : str\n        Frequency scaling to use, can be "log" (default) or "linear".\n    alim : tuple\n        If not None (default), the y-axis limits (dB) to use.\n    color : color object\n        The color to use (default: \'r\').\n    alpha : float\n        The alpha to use (default: 0.5).\n    linestyle : str\n        The line style to use (default: \'--\').\n    show : bool\n        Show figure if True (default).\n\n    Returns\n    -------\n    fig : instance of matplotlib.figure.Figure\n        The figure.\n\n    See Also\n    --------\n    plot_filter\n\n    Notes\n    -----\n    .. versionadded:: 0.14\n\n    Examples\n    --------\n    Plot a simple ideal band-pass filter::\n\n        >>> from mne.viz import plot_ideal_filter\n        >>> freq = [0, 1, 40, 50]\n        >>> gain = [0, 1, 1, 0]\n        >>> plot_ideal_filter(freq, gain, flim=(0.1, 100))  #doctest: +ELLIPSIS\n        <...Figure...>\n    '
    import matplotlib.pyplot as plt
    (my_freq, my_gain) = (list(), list())
    if (freq[0] != 0):
        raise ValueError(('freq should start with DC (zero) and end with Nyquist, but got %s for DC' % (freq[0],)))
    freq = np.array(freq)
    _check_option('fscale', fscale, ['log', 'linear'])
    if (fscale == 'log'):
        freq[0] = ((0.1 * freq[1]) if (flim is None) else min(flim[0], freq[1]))
    flim = _get_flim(flim, fscale, freq)
    transitions = list()
    for ii in range(len(freq)):
        if ((ii < (len(freq) - 1)) and (gain[ii] != gain[(ii + 1)])):
            transitions += [[freq[ii], freq[(ii + 1)]]]
            my_freq += np.linspace(freq[ii], freq[(ii + 1)], 20, endpoint=False).tolist()
            my_gain += np.linspace(gain[ii], gain[(ii + 1)], 20, endpoint=False).tolist()
        else:
            my_freq.append(freq[ii])
            my_gain.append(gain[ii])
    my_gain = (10 * np.log10(np.maximum(my_gain, (10 ** (alim[0] / 10.0)))))
    if (axes is None):
        axes = plt.subplots(1)[1]
    for transition in transitions:
        axes.axvspan(*transition, color=color, alpha=0.1)
    axes.plot(my_freq, my_gain, color=color, linestyle=linestyle, alpha=0.5, linewidth=4, zorder=3)
    (xticks, xticklabels) = _filter_ticks(flim, fscale)
    axes.set(ylim=alim, xlabel='Frequency (Hz)', ylabel='Amplitude (dB)', xscale=fscale)
    if (xticks is not None):
        axes.set(xticks=xticks)
        axes.set(xticklabels=xticklabels)
    axes.set(xlim=flim)
    if title:
        axes.set(title=title)
    adjust_axes(axes)
    tight_layout()
    plt_show(show)
    return axes.figure