code: def plot_basis_kernels(
      learner, support=None, basis_kernels=None, n_points=300, show=True
  ):
      """Function used to plot basis of kernels
  
      It is used jointly with `tick.hawkes.inference.HawkesBasisKernels` learner class.
  
      Parameters
      ----------
      learner : `HawkesBasisKernels`
          The given learner which basis kernels are plotted
  
      support : `float`, default=None
          the size of the support that will be used to plot all the kernels.
          If None or non positive then the maximum kernel supports is used
  
      basis_kernels : `list` of `func`, default=None
          True basis kernels. If not `None`, it will find the closest estimated
          basis kernel and will plot it together.
          This basis kernels will be normalized to fit better with their
          estimations.
  
      n_points : `int`, default=300
          Number of points that will be used in abscissa. More points will lead
          to a more precise graph.
  
      show : `bool`, default=`True`
          if `True`, show the plot. Otherwise an explicit call to the show
          function is necessary. Useful when superposing several plots.
      """
      if support is None or support <= 0:
          support = learner.kernel_support
  
      fig, ax_list = plt.subplots(
          1, learner.n_basis, figsize=(8, 4), sharey=True
      )
  
      if basis_kernels is not None:
          if len(basis_kernels) != learner.n_basis:
              raise ValueError(
                  "Learner has {} basis kernels, cannot "
                  "compare to {} basis kernels".format(
                      learner.n_basis, len(basis_kernels)
                  )
              )
  
          t_values = learner.kernel_discretization[:-1]
  
          basis_values_list = [
              basis_kernel(t_values) for basis_kernel in basis_kernels
          ]
          (
              normalized_basis_kernels,
              basis_normalizations,
          ) = _normalize_functions(basis_values_list, t_values)
  
          (
              normalized_estimates,
              estimated_normalizations,
          ) = _normalize_functions(learner.basis_kernels, t_values)
  
          kernel_diff = np.array(
              [
                  [
                      np.trapz(np.abs(nbf - ne), t_values)
                      for nbf in normalized_basis_kernels
                  ]
                  for ne in normalized_estimates
              ]
          )
  
          matches = _find_best_match(kernel_diff)
  
          t_values = np.linspace(0, support, n_points)
          for estimated_index, basis_index in matches:
              basis_kernel = basis_kernels[basis_index]
              estimated = learner.basis_kernels[estimated_index]
  
              piecewise_y = np.repeat(estimated, 2)
              piecewise_t = np.hstack(
                  (
                      learner.kernel_discretization[0],
                      np.repeat(learner.kernel_discretization[1:-1], 2),
                      learner.kernel_discretization[-1],
                  )
              )
  
              ax_list[basis_index].step(
                  piecewise_t,
                  piecewise_y,
                  label="estimated %i" % estimated_index,
              )
              rescaled_basis = (
                  basis_kernel(t_values)
                  * basis_normalizations[basis_index]
                  / estimated_normalizations[estimated_index]
              )
              ax_list[basis_index].plot(
                  t_values,
                  rescaled_basis,
                  label="true basis %i" % basis_index,
              )
  
              legend = ax_list[basis_index].legend()
              for label in legend.get_texts():
                  label.set_fontsize(12)
  
      else:
          for estimated_index in range(learner.n_basis):
              estimated = learner.basis_kernels[estimated_index]
  
              piecewise_y = np.repeat(estimated, 2)
              piecewise_t = np.hstack(
                  (
                      learner.kernel_discretization[0],
                      np.repeat(learner.kernel_discretization[1:-1], 2),
                      learner.kernel_discretization[-1],
                  )
              )
  
              ax_list[estimated_index].plot(
                  piecewise_t,
                  piecewise_y,
                  label="estimated %i" % estimated_index,
              )
              legend = ax_list[estimated_index].legend()
              for label in legend.get_texts():
                  label.set_fontsize(12)
  
      if show:
          plt.show()
  
      return fig
  
file_path: tick/tick/plot/plot_hawkes.py
imports: import matplotlib.pyplot
  import numpy
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  from tick.plot.plot_utilities import share_x, share_y
label_desc: Use image node_id 6 for calling a global function with example usage: plot_basis_kernels(learner, support, basis_kernels, n_points, show) and returns: fig