code: def gen_curves(
      plot_order,
      results,
      x_label,
      y_label,
      plot_legends,
      plot_colours,
      plot_markers,
      plot_linestyles,
      options,
      x_bounds=None,
      y_bounds=None,
      outlier_frac=0.1,
      log_y=False,
      log_x=False,
      plot_title=None,
      study_name=None,
      num_workers=None,
      time_distro_str=None,
      fill_error=False,
      err_bar_freq=5,
      plot_type="semilogy",
      to_plot_legend=True,
      true_maxval=None,
  ):
      # pylint: disable=too-many-arguments
      # pylint: disable=too-many-branches
      # pylint: disable=too-many-statements
      # pylint: disable=unused-argument
      # pylint: disable=unused-variable
      """Plots the curves given the experiment results."""
  
      num_methods, num_experiments = results["curr_opt_vals"].shape
      if true_maxval is None:
          true_maxval = np.asscalar(results["true_maxval"])
  
      if true_maxval is None or not np.isfinite(true_maxval):
          to_plot_regret = False
      else:
          to_plot_regret = True
          plot_type = "semilogy"
          y_label = "Regret"
  
      methods = [str(method).strip() for method in results["methods"]]
      # Exclude incomplete experiments if present in any of the methods
      for i in range(num_methods):
          for vals in results["curr_opt_vals"][i, num_experiments::-1]:
              if isinstance(vals, str) or vals.dtype == np.dtype("<U1"):
                  num_experiments = num_experiments - 1
  
      if x_bounds is None or x_bounds == []:
          x_bounds = [0.0, np.asscalar(results["max_capital"])]
  
      if log_x:
          grid_pts = np.logspace(
              np.log10(x_bounds[0]),
              np.log10(x_bounds[1]),
              num=NUM_GRID_PTS,
          )
      else:
          grid_pts = np.linspace(
              x_bounds[0], x_bounds[1], num=NUM_GRID_PTS
          )
  
      err_bar_idx_half_gap = 0.5 * NUM_GRID_PTS / NUM_ERR_BARS
      err_bar_idxs = np.round(
          np.linspace(
              err_bar_idx_half_gap,
              NUM_GRID_PTS - err_bar_idx_half_gap,
              num=NUM_ERR_BARS,
          )
      ).astype(np.int)
  
      unordered_plot_means = np.zeros((num_methods, NUM_GRID_PTS))
      unordered_plot_stds = np.zeros((num_methods, NUM_GRID_PTS))
      init_opt_vals = None
  
      for i in range(num_methods):
          meth_curr_opt_vals = results["curr_true_opt_vals"][i, :]
          meth_costs = results["query_eval_times"][i, :]
          cum_costs = results["query_receive_times"][i, :]
          meth_plot_mean, meth_plot_std = get_plot_info(
              meth_curr_opt_vals,
              cum_costs,
              meth_costs,
              grid_pts,
              outlier_frac,
              init_opt_vals,
              num_experiments,
          )
  
          if to_plot_regret:
              unordered_plot_means[i, :] = true_maxval - meth_plot_mean
          else:
              unordered_plot_means[i, :] = meth_plot_mean
          unordered_plot_stds[i, :] = meth_plot_std
  
      # re-order plot_means
      plot_means = np.zeros((num_methods, NUM_GRID_PTS))
      plot_stds = np.zeros((num_methods, NUM_GRID_PTS))
      for plot_idx, method in enumerate(plot_order):
          saved_order = methods.index(method)
          plot_means[plot_idx, :] = unordered_plot_means[saved_order, :]
          plot_stds[plot_idx, :] = unordered_plot_stds[saved_order, :]
  
      # Print out some statistics about plot_means
      all_plot_vals = plot_means.flatten()
      all_plot_vals = all_plot_vals[np.isfinite(all_plot_vals)]
      percentiles = [0.001, 0.1, 0.5, 0.9, 0.999]
      percentile_vals = np.percentile(all_plot_vals, percentiles)
      print_percentile_list = [
          "%0.3f:%0.4f" % (p, v)
          for (p, v) in zip(percentiles, percentile_vals)
      ]
      print("Percentiles:: %s." % (",  ".join(print_percentile_list)))
  
      err_bar_pts = grid_pts[err_bar_idxs]
      err_bar_means = plot_means[:, err_bar_idxs]
      err_bar_stds = plot_stds[:, err_bar_idxs]
  
      if plot_type == "plot":
          plot_func = plt.plot
      elif plot_type == "loglog":
          plot_func = plt.loglog
      elif plot_type == "semilogy":
          plot_func = plt.semilogy
      elif plot_type == "semilogx":
          plot_func = plt.semilogx
      else:
          raise ValueError("Unknown plot function.")
  
      first_lines_for_legend = []
  
      # First the bars for the legend
      #   for i, method in enumerate(methods):
      for plot_idx, method in enumerate(plot_order):
          # First plot the error bars
          (curr_leg_line,) = plot_func(
              err_bar_pts,
              err_bar_means[plot_idx],
              marker=plot_markers[plot_idx],
              color=plot_colours[plot_idx],
              label=plot_legends[plot_idx],
              linewidth=LINE_WIDTH,
              linestyle=plot_linestyles[plot_idx],
              markersize=MARKER_SIZE,
          )
          first_lines_for_legend.append(curr_leg_line)
      if to_plot_legend:
          plt.legend(loc=options.legend_location, fontsize="large")
      # Now plot the whole curve
      for plot_idx, method in enumerate(plot_order):
          plot_func(
              grid_pts,
              plot_means[plot_idx, :],
              marker=",",
              color=plot_colours[plot_idx],
              linestyle=plot_linestyles[plot_idx],
              linewidth=LINE_WIDTH,
          )
      # Now do the error bars
      for plot_idx, method in enumerate(plot_order):
          if not fill_error:
              plt.errorbar(
                  err_bar_pts,
                  err_bar_means[plot_idx],
                  err_bar_stds[plot_idx],
                  marker=plot_markers[plot_idx],
                  color=plot_colours[plot_idx],
                  linewidth=LINE_WIDTH,
                  markersize=MARKER_SIZE,
                  linestyle="",
              )
          else:
              plt.fill_between(
                  grid_pts,
                  plot_means[i, :] - plot_stds[i, :],
                  plot_means[i, :] + plot_stds[i, :],
                  color=transparent(
                      *plot_colours[plot_idx], opacity=0.3
                  ),
              )
  
      if plot_title is not None:
          plt.title(plot_title, fontsize=TITLE_FONT_SIZE)
      #   if to_plot_regret:
      #     plt.title('{}; workers={}; {}; Exps={}; Max Val={}'.format(study_name, num_workers,
      #                       time_distro_str, num_experiments, true_maxval).replace('_', '-'))
      #   else:
      #     plt.title('{}; Workers={}; {}; Exps={}'.format(study_name, num_workers,
      #                       time_distro_str, num_experiments).replace('_', '-'))
      plt.xlabel(x_label, fontsize=AXIS_FONT_SIZE)
      plt.ylabel(y_label, fontsize=AXIS_FONT_SIZE)
      if y_bounds is not None:
          plt.ylim(y_bounds)
      # Remove duplicate lines
      for leg_line in first_lines_for_legend:
          leg_line.remove()
      plt.draw()
      plt.show()
  
file_path: dragonfly/dragonfly/utils/plot_utils.py
imports: from __future__ import division
  import pickle
  import argparse
  import matplotlib.pyplot
  import matplotlib
  from scipy.io import loadmat
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: gen_curves(plot_order, results, x_label, y_label, plot_legends, plot_colours, plot_markers, plot_linestyles, options, x_bounds, y_bounds, outlier_frac, log_y, log_x, plot_title, study_name, num_workers, time_distro_str, fill_error, err_bar_freq, plot_type, to_plot_legend, true_maxval) without return types