code: def plot_contour(
      pos_history,
      canvas=None,
      title="Trajectory",
      mark=None,
      designer=None,
      mesher=None,
      animator=None,
      n_processes=None,
      **kwargs,
  ):
      """Draw a 2D contour map for particle trajectories
  
      Here, the space is represented as a flat plane. The contours indicate the
      elevation with respect to the objective function. This works best with
      2-dimensional swarms with their fitness in z-space.
  
      Parameters
      ----------
      pos_history : numpy.ndarray or list
          Position history of the swarm with shape
          :code:`(iteration, n_particles, dimensions)`
      canvas : (:obj:`matplotlib.figure.Figure`, :obj:`matplotlib.axes.Axes`),
          The (figure, axis) where all the events will be draw. If :code:`None`
          is supplied, then plot will be drawn to a fresh set of canvas.
      title : str, optional
          The title of the plotted graph. Default is `Trajectory`
      mark : tuple, optional
          Marks a particular point with a red crossmark. Useful for marking
          the optima.
      designer : :obj:`pyswarms.utils.formatters.Designer`, optional
          Designer class for custom attributes
      mesher : :obj:`pyswarms.utils.formatters.Mesher`, optional
          Mesher class for mesh plots
      animator : :obj:`pyswarms.utils.formatters.Animator`, optional
          Animator class for custom animation
      n_processes : int
          number of processes to use for parallel mesh point calculation (default: None = no parallelization)
      **kwargs : dict
          Keyword arguments that are passed as a keyword argument to
          :obj:`matplotlib.axes.Axes` plotting function
  
      Returns
      -------
      :obj:`matplotlib.animation.FuncAnimation`
          The drawn animation that can be saved to mp4 or other
          third-party tools
      """
  
      try:
          # If no Designer class supplied, use defaults
          if designer is None:
              designer = Designer(
                  limits=[(-1, 1), (-1, 1)], label=["x-axis", "y-axis"]
              )
  
          # If no Animator class supplied, use defaults
          if animator is None:
              animator = Animator()
  
          # If ax is default, then create new plot. Set-up the figure, the
          # axis, and the plot element that we want to animate
          if canvas is None:
              fig, ax = plt.subplots(1, 1, figsize=designer.figsize)
          else:
              fig, ax = canvas
  
          # Get number of iterations
          n_iters = len(pos_history)
  
          # Customize plot
          ax.set_title(title, fontsize=designer.title_fontsize)
          ax.set_xlabel(
              designer.label[0], fontsize=designer.text_fontsize
          )
          ax.set_ylabel(
              designer.label[1], fontsize=designer.text_fontsize
          )
          ax.set_xlim(designer.limits[0])
          ax.set_ylim(designer.limits[1])
  
          # Make a contour map if possible
          if mesher is not None:
              (xx, yy, zz) = _mesh(mesher, n_processes=n_processes)
              ax.contour(xx, yy, zz, levels=mesher.levels)
  
          # Mark global best if possible
          if mark is not None:
              ax.scatter(mark[0], mark[1], color="red", marker="x")
  
          # Put scatter skeleton
          plot = ax.scatter(x=[], y=[], c="black", alpha=0.6, **kwargs)
  
          # Do animation
          anim = animation.FuncAnimation(
              fig=fig,
              func=_animate,
              frames=range(n_iters),
              fargs=(pos_history, plot),
              interval=animator.interval,
              repeat=animator.repeat,
              repeat_delay=animator.repeat_delay,
          )
      except TypeError:
          rep.logger.exception("Please check your input type")
          raise
      else:
          return anim
  
file_path: pyswarms/pyswarms/utils/plotters/plotters.py
imports: import logging
  import matplotlib.pyplot
  import numpy
  import multiprocessing
  from matplotlib import animation, cm
  from mpl_toolkits.mplot3d import Axes3D
  from ..reporter import Reporter
  from .formatters import Animator, Designer
label_desc: Use image node_id 2 for calling a global function with example usage: plot_contour(pos_history, canvas, title, mark, designer, mesher, animator, n_processes) and returns: anim