code: def main_plot_history(
      trials, bandit=None, algo=None, do_show=True, status_colors=None
  ):
      # -- import here because file-level import is too early
      import matplotlib.pyplot as plt
  
      # self is an Experiment
      if status_colors is None:
          status_colors = default_status_colors
  
      # XXX: show the un-finished or error trials
      Ys, colors = zip(
          *[
              (y, status_colors[s])
              for y, s in zip(
                  trials.losses(bandit), trials.statuses(bandit)
              )
              if y is not None
          ]
      )
      plt.scatter(range(len(Ys)), Ys, c=colors)
      plt.xlabel("time")
      plt.ylabel("loss")
  
      if bandit is not None and bandit.loss_target is not None:
          plt.axhline(bandit.loss_target)
          ymin = min(np.min(Ys), bandit.loss_target)
          ymax = max(np.max(Ys), bandit.loss_target)
          yrange = ymax - ymin
          ymean = (ymax + ymin) / 2.0
          plt.ylim(
              ymean - 0.53 * yrange,
              ymean + 0.53 * yrange,
          )
      best_err = trials.average_best_error(bandit)
      print("avg best error:", best_err)
      plt.axhline(best_err, c="g")
  
      plt.title(
          "bandit: %s algo: %s"
          % (bandit.short_str() if bandit else "-", algo_as_str(algo))
      )
      if do_show:
          plt.show()
  
file_path: auptimizer/src/aup/Proposer/hyperopt/plotting.py
imports: from __future__ import print_function
  import math
  import sys
  from past.builtins import xrange
  from hyperopt.mongoexp import MongoJobs
  import numpy
  from .None import base
  from .base import miscs_to_idxs_vals
label_desc: Use image node_id 2 for calling a global function with example usage: main_plot_history(trials, bandit, algo, do_show, status_colors) without return types