code: def plot_history(
      solvers,
      x="n_iter",
      y="obj",
      labels=None,
      show=True,
      log_scale: bool = False,
      dist_min: bool = False,
      rendering: str = "matplotlib",
      ax=None,
  ):
      """Plot the history of convergence of learners or solvers.
  
      It is used to compare easily their convergence performance.
  
      Parameters
      ----------
      solvers : `list` of `object` with and history to plot, namely solvers
          (children of `tick.solver.base.Solver`) or learners (children of
          `tick.hawkes.inference.base.LearnerOptim`)
  
      x : `str`, default='n_iter'
          - if 'n_iter' : iteration number
          - if 'time' : computation time
  
      y : `str`, default='obj'
          - if 'obj' : the objective (value of the function minimized).
              Other choices are possible, any of those present in the
              history
  
      labels : `list` of `str`, default=None
          Label of each solver in the legend. If set to None then the class
          name of each solver will be used.
  
      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 y-axis is on a log-scale
  
      dist_min : `bool`, default=`False`
          If `True`, plot the difference between `y` of each solver and the
          minimal `y` of all solvers. This is useful when comparing solvers on
          a logarithmic scale, to illustrate linear convergence of algorithms
  
      rendering : {'matplotlib', 'bokeh'}, default='matplotlib'
          Rendering library. 'bokeh' might fail if the module is not installed.
  
      ax : `list` of `matplotlib.axes`, default=None
          If not None, the figure will be plot on this axis and show will be
          set to False. Used only with matplotlib
      """
      x_arrays, y_arrays, labels = extract_history(
          solvers, x, y, labels
      )
  
      if dist_min:
          min_y = np.min(np.hstack(y_arrays))
          y_arrays = [y_array - min_y for y_array in y_arrays]
  
      min_x, max_x = np.min(np.hstack(x_arrays)), np.max(
          np.hstack(x_arrays)
      )
      min_y, max_y = np.min(np.hstack(y_arrays)), np.max(
          np.hstack(y_arrays)
      )
  
      # We want to ensure theses plots starts at 0
      if x in ["time", "n_iter"]:
          min_x = 0
  
      if rendering == "matplotlib":
          if ax is None:
              _, ax = plt.subplots(1, 1, figsize=(8, 4))
          else:
              show = False
  
          for i, (solver, x_array, y_array, label) in enumerate(
              zip(solvers, x_arrays, y_arrays, labels)
          ):
              color = get_plot_color(i)
              ax.plot(x_array, y_array, lw=3, label=label, color=color)
  
          if log_scale:
              ax.set_yscale("log")
  
          ax.set_xlabel(x, fontsize=16)
          ax.set_ylabel(y, fontsize=16)
          ax.set_xlim([min_x, max_x])
          ax.set_ylim([min_y, max_y])
          ax.tick_params(axis="both", which="major", labelsize=12)
          ax.legend()
  
          if show is True:
              plt.show()
  
          return ax.figure
  
      elif rendering == "bokeh":
          mins = (min_x, max_x, min_y, max_y)
          return plot_bokeh_history(
              solvers,
              x,
              y,
              x_arrays,
              y_arrays,
              mins,
              labels,
              log_scale,
              show,
          )
  
      else:
          raise ValueError(
              "Unknown rendering type. Expected 'matplotlib' or "
              "'bokeh', received %s" % rendering
          )
  
imports: import matplotlib.pyplot
  import numpy
  from tick.base.learner import LearnerOptim
  from tick.plot.plot_utilities import get_plot_color
  from tick.solver.base import Solver
label_desc: Use image node_id 2 for calling a global function with example usage: plot_history(solvers, x, y, labels, show, log_scale, dist_min, rendering, ax) and returns: ax, plot_bokeh_history