code: def plot_hawkes_kernels(
      kernel_object,
      support=None,
      hawkes=None,
      n_points=300,
      show=True,
      log_scale=False,
      min_support=1e-4,
      ax=None,
  ):
      """Generic function to plot Hawkes kernels.
  
      Parameters
      ----------
      kernel_object : `Object`
          An object that must have the following API :
  
          * `kernel_object.n_nodes` : a field that stores the number of nodes
            of the associated Hawkes process (thus the number of kernels is
            this number squared)
          * `kernel_object.get_kernel_supports()` : must return a 2d numpy
            array with the size of the support of each kernel
          * `kernel_object.get_kernel_values(self, i, j, abscissa_array)` :
            must return as a numpy 1d array the sampled `(i,j)` kernel values
            corresponding to the abscissa `abscissa_array`
  
      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
  
      hawkes : `SimuHawkes`, default=None
          If a `SimuHawkes` object is given then the kernels plots are superposed
          with those of this object (considered as the `True` kernels). This is
          used to plot on the same plots the estimated kernels along with
          the true kernels.
  
      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.
  
      log_scale : `bool`, default=`False`
          If `True`, then x-axis and y-axis are on a log-scale. This is useful
          to plot power-law kernels.
  
      min_support : `float`, default=1e-4
          Start value of the plot. Only used if log_scale is `True`.
  
      ax : `np.ndarray` of `matplotlib.axes`, default=None
          If not None, the figure will be plot on these axes and show will be
          set to False.
      """
      if support is None or support <= 0:
          plot_supports = kernel_object.get_kernel_supports()
          support = plot_supports.max() * 1.2
  
      n_nodes = kernel_object.n_nodes
  
      if log_scale:
          x_values = np.logspace(
              np.log10(min_support), np.log10(support), n_points
          )
      else:
          x_values = np.linspace(0, support, n_points)
  
      if ax is None:
          fig, ax_list_list = plt.subplots(
              n_nodes, n_nodes, sharex=True, sharey=True
          )
      else:
          if ax.shape != (n_nodes, n_nodes):
              raise ValueError(
                  "Given ax has shape {} but should have shape {}".format(
                      ax.shape, (n_nodes, n_nodes)
                  )
              )
          ax_list_list = ax
          show = False
  
      if n_nodes == 1:
          ax_list_list = np.array([[ax_list_list]])
  
      for i, ax_list in enumerate(ax_list_list):
          for j, ax in enumerate(ax_list):
              y_values = kernel_object.get_kernel_values(i, j, x_values)
              ax.plot(
                  x_values, y_values, label="Kernel (%d, %d)" % (i, j)
              )
  
              if hawkes:
                  y_true_values = hawkes.kernels[i, j].get_values(
                      x_values
                  )
                  ax.plot(
                      x_values,
                      y_true_values,
                      label="True Kernel (%d, %d)" % (i, j),
                  )
  
              # set x_label for last line
              if i == n_nodes - 1:
                  ax.set_xlabel(r"$t$", fontsize=18)
  
              ax.set_ylabel(r"$\phi^{%g,%g}(t)$" % (i, j), fontsize=18)
  
              if log_scale:
                  ax.set_xscale("log")
                  ax.set_yscale("log")
  
              legend = ax.legend()
              for label in legend.get_texts():
                  label.set_fontsize(12)
  
      if show:
          plt.show()
  
      return ax_list_list.ravel()[0].figure
  
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 2 for calling a global function with example usage: plot_hawkes_kernels(kernel_object, support, hawkes, n_points, show, log_scale, min_support, ax) and returns: ax_list_list