docs: def plot_connectivity_spectrum(a, fs=2, freq_range=(-np.inf, np.inf), diagonal=0, border=False, fig=None):
      """Draw connectivity plots.
  
      Parameters
      ----------
      a : array, shape (n_channels, n_channels, n_fft) or (1 or 3, n_channels, n_channels, n_fft)
          If a.ndim == 3, normal plots are created,
          If a.ndim == 4 and a.shape[0] == 1, the area between the curve and y=0 is filled transparently,
          If a.ndim == 4 and a.shape[0] == 3, a[0,:,:,:] is plotted normally and the area between a[1,:,:,:] and
          a[2,:,:,:] is filled transparently.
      fs : float
          Sampling frequency
      freq_range : (float, float)
          Frequency range to plot
      diagonal : {-1, 0, 1}
          If diagonal == -1 nothing is plotted on the diagonal (a[i,i,:] are not plotted),
          if diagonal == 0, a is plotted on the diagonal too (all a[i,i,:] are plotted),
          if diagonal == 1, a is plotted on the diagonal only (only a[i,i,:] are plotted)
      border : bool
          If border == true the leftmost column and the topmost row are left blank
      fig : Figure object, optional
          Figure to plot into. If set to `None`, a new figure is created.
  
      Returns
      -------
      fig : Figure object
          The figure into which was plotted.
      """
  
      a = np.atleast_3d(a)
      if a.ndim == 3:
          [_, m, f] = a.shape
          l = 0
      else:
          [l, _, m, f] = a.shape
      freq = np.linspace(0, fs / 2, f)
  
      lowest, highest = np.inf, 0
      left = max(freq_range[0], freq[0])
      right = min(freq_range[1], freq[-1])
  
      if fig is None:
          fig = new_figure()
  
      axes = []
      for i in range(m):
          if diagonal == 1:
              jrange = [i]
          elif diagonal == 0:
              jrange = range(m)
          else:
              jrange = [j for j in range(m) if j != i]
          for j in jrange:
              if border:
                  ax = fig.add_subplot(m+1, m+1, j + (i+1) * (m+1) + 2)
              else:
                  ax = fig.add_subplot(m, m, j + i * m + 1)
              axes.append((i, j, ax))
              if l == 0:
                  ax.plot(freq, a[i, j, :])
                  lowest = min(lowest, np.min(a[i, j, :]))
                  highest = max(highest, np.max(a[i, j, :]))
              elif l == 1:
                  ax.fill_between(freq, 0, a[0, i, j, :], facecolor=[0.25, 0.25, 0.25], alpha=0.25)
                  lowest = min(lowest, np.min(a[0, i, j, :]))
                  highest = max(highest, np.max(a[0, i, j, :]))
              else:
                  baseline,  = ax.plot(freq, a[0, i, j, :])
                  ax.fill_between(freq, a[1, i, j, :], a[2, i, j, :], facecolor=baseline.get_color(), alpha=0.25)
                  lowest = min(lowest, np.min(a[:, i, j, :]))
                  highest = max(highest, np.max(a[:, i, j, :]))
  
      for i, j, ax in axes:
          ax.xaxis.set_major_locator(MaxNLocator(max(4, 10 - m)))
          ax.yaxis.set_major_locator(MaxNLocator(max(4, 10 - m)))
          ax.set_ylim(0, highest)
          ax.set_xlim(left, right)
  
          if 0 < i < m - 1:
              ax.set_xticklabels([])
          ax.set_yticklabels([])
  
          if i == 0:
              ax.xaxis.set_tick_params(labeltop="on", labelbottom="off")
          if j == m-1:
              ax.yaxis.set_tick_params(labelright="on", labelleft="off")
  
          ax.tick_params(labelsize=10)
  
      _plot_labels(fig, {'x': 0.5, 'y': 0.025, 's': 'f (Hz)',
                         'horizontalalignment': 'center'})
  
      return fig