code: def _draw_trajectory(
      x, y, cost=None, scale=True, shift=False, style=None, figure=None
  ):
      """draw a solution trajectory (for overlay on a contour plot)
  
      x is a sequence of values for one parameter (i.e. a parameter trajectory)
      y is a sequence of values for one parameter (i.e. a parameter trajectory)
      cost is the solution trajectory (i.e. costs); if provided, plot a 3D contour
      if scale is provided, scale the intensity as 'z = log(4*z*scale+1)+2'
      if shift is provided, shift the intensity as 'z = z+shift' (useful for -z's)
      if style is provided, set the line style (e.g. 'w-o', 'k-', 'ro')
      if figure is provided, plot to an existing figure
      """
      import matplotlib.pyplot as plt
      from mpl_toolkits.mplot3d import axes3d
  
      if not figure:
          figure = plt.figure()
  
      if cost:
          kwds = {"projection": "3d"}  # 3D
      else:
          kwds = {}  # 2D
      ax = figure.axes[0] if figure.axes else plt.axes(**kwds)
  
      if style in [None, False]:
          style = "w-o"  # if not scale else 'k-o'
      if cost:  # is 3D, cost is needed
          import numpy
  
          if shift:
              if shift is True:  # NOTE: MAY NOT be the exact minimum
                  shift = (
                      max(-numpy.min(cost), 0.0) + 0.5
                  )  # a good guess
              cost = numpy.asarray(cost) + shift
          if scale:
              cost = numpy.asarray(cost)
              cost = numpy.log(4 * cost * scale + 1) + 2
          x = numpy.asarray(x).reshape(-1)
          y = numpy.asarray(y).reshape(-1)
          ax.plot(x, y, cost, style, linewidth=2, markersize=4)
          # XXX: need to 'correct' the z-axis (or provide easy conversion)
      else:  # is 2D, cost not needed
          ax.plot(x, y, style, linewidth=2, markersize=4)
      return figure
  
imports: from collections.abc import Callable
label_desc: Use image node_id 23 for calling a global function with example usage: _draw_trajectory(x, y, cost, scale, shift, style, figure) and returns: figure