code: def box(
      coeffs,
      n_inputs,
      ax,
      colour_dict=None,
      show_freqs=True,
      show_fliers=True,
  ):
      """Plot a list of sets of Fourier coefficients as a box plot.
  
      Args:
          coeffs (list[array[complex]]): A list of sets of Fourier coefficients. The shape of the
              coefficient arrays should resemble that of the output of numpy/scipy's ``fftn``
              function, or :func:`~.pennylane.fourier.coefficients`.
          n_inputs (int): The number of input variables in the function.
          ax (array[matplotlib.axes.Axes]): Axis on which to plot. Must
              be a pair of axes from a subplot where ``sharex="row"`` and ``sharey="col"``.
          colour_dict (dict[str, str]): A dictionary of the form {"real" : colour_string,
              "imag" : other_colour_string} indicating which colours should be used in the plot.
          show_freqs (bool): Whether or not to print the frequency labels on the plot axis.
          show_fliers (bool): Whether to display the box plot outliers.
  
      Returns:
          array[matplotlib.axes.Axes]: The axes after plotting is complete.
  
      **Example**
  
      Suppose we have the following quantum function:
  
      .. code-block:: python
  
          dev = qml.device('default.qubit', wires=2)
  
          @qml.qnode(dev)
          def circuit_with_weights(w, x):
              qml.RX(x[0], wires=0)
              qml.RY(x[1], wires=1)
              qml.CNOT(wires=[1, 0])
  
              qml.Rot(*w[0], wires=0)
              qml.Rot(*w[1], wires=1)
              qml.CNOT(wires=[1, 0])
  
              qml.RX(x[0], wires=0)
              qml.RY(x[1], wires=1)
              qml.CNOT(wires=[1, 0])
  
              return qml.expval(qml.PauliZ(0))
  
      We would like to compute and plot the distribution of Fourier coefficients
      for many random values of the weights ``w``. First, we generate all the coefficients:
  
      .. code-block:: python
  
          from functools import partial
  
          coeffs = []
  
          n_inputs = 2
          degree = 2
  
          for _ in range(100):
              weights = np.random.normal(0, 1, size=(2, 3))
              c = coefficients(partial(circuit_with_weights, weights), n_inputs, degree)
              coeffs.append(c)
  
      We can now plot by setting up a pair of ``matplotlib`` axes and passing them
      to the plotting function:
  
      >>> import matplotlib.pyplot as plt
      >>> from pennylane.fourier.visualize import box
      >>> fig, ax = plt.subplots(2, 1, sharey=True, figsize=(15, 4))
      >>> box(coeffs, n_inputs, ax, show_freqs=True)
  
      .. image:: ../../_static/fourier_vis_box.png
          :align: center
          :width: 800px
          :target: javascript:void(0);
      """
      coeffs = _validate_coefficients(coeffs, n_inputs, True)
  
      # Check axis shape
      if ax.size != 2:
          raise ValueError(
              "Matplotlib axis should consist of two subplots."
          )
  
      # The axis received must be a pair of axes in a subplot.
      if colour_dict is None:
          colour_dict = {"real": "purple", "imag": "green"}
  
      # Get the labels and data
      nvecs_formatted, data = _extract_data_and_labels(coeffs)
  
      for data_type, axis in zip(["real", "imag"], ax):
          data_colour = colour_dict[data_type]
          axis.boxplot(
              data[data_type],
              boxprops={
                  "facecolor": to_rgb(data_colour) + (0.4,),
                  "color": data_colour,
                  "edgecolor": data_colour,
              },
              medianprops={"color": data_colour, "linewidth": 1.5},
              flierprops={"markeredgecolor": data_colour},
              whiskerprops={"color": data_colour},
              capprops={"color": data_colour},
              patch_artist=True,
              showfliers=show_fliers,
          )
  
          _adjust_spine_placement(axis)
          axis.set_ylabel(data_type)
          axis.xaxis.set_ticks(np.arange(1, len(nvecs_formatted) + 1))
  
      ax[0].tick_params(
          axis="x", colors="white"
      )  # hack to get rid of ticks but keep grid
  
      if show_freqs:
          ax[1].tick_params(
              axis="x", which="both", length=0
          )  # remove ticks without removing labels
          ax[1].xaxis.set_ticklabels(
              nvecs_formatted, fontsize=10, color="grey"
          )
          ax[1].xaxis.set_ticks_position("top")
      else:
          ax[1].tick_params(
              axis="x", colors="white"
          )  # hack to get rid of ticks but keep grid
  
      return ax
  
file_path: pennylane/pennylane/fourier/visualize.py
imports: from itertools import product
  import numpy
  from .utils import format_nvec
label_desc: Use image node_id 5 for calling a global function with example usage: box(coeffs, n_inputs, ax, colour_dict, show_freqs, show_fliers) and returns: ax