code: 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.
  
      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: +SKIP
          <...Figure...>
      """
      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)
      # deal with semilogx problems @ x=0
      _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, layout="constrained")[1]
      for transition in transitions:
          axes.axvspan(*transition, color=color, alpha=0.1)
      axes.plot(
          my_freq,
          my_gain,
          color=color,
          linestyle=linestyle,
          alpha=alpha,
          linewidth=2,
          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)
      plt_show(show)
      return axes.figure
  
imports: import copy
  import io
  import os
  import os.path
  import warnings
  from collections import defaultdict
  from glob import glob
  from itertools import cycle
  from pathlib import Path
  import numpy
  from scipy.signal import filtfilt, freqz, group_delay, lfilter, sosfilt, sosfiltfilt
  from .._fiff.constants import FIFF
  from .._fiff.pick import _DATA_CH_TYPES_SPLIT, _picks_by_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import make_projector
  from .._freesurfer import _check_mri, _mri_orientation, _read_mri_info, _reorient_image
  from ..defaults import DEFAULTS
  from ..filter import estimate_ringing_samples
  from ..fixes import _safe_svd
  from ..rank import compute_rank
  from ..surface import read_surface
  from ..transforms import _frame_to_str, apply_trans
  from ..utils import _check_option, _mask_to_onsets_offsets, _on_missing, _pl, fill_doc, get_subjects_dir, logger, verbose, warn
  from .utils import _figure_agg, _get_color_list, _prepare_trellis, _validate_type, plt_show
label_desc: Use image node_id 15 for calling a global function with example usage: plot_ideal_filter(freq, gain, axes, title, flim, fscale, alim, color, alpha, linestyle, show) and returns: axes