code: def plot_threshold_optimizer(
      threshold_optimizer, ax=None, show_plot=True
  ):
      """Plot the chosen solution of the threshold optimizer.
  
      For `fairlearn.postprocessing.ThresholdOptimizer` objects that have their
      constraint set to `'demographic_parity'` this will result in a
      selection/error curve plot. For `fairlearn.postprocessing.ThresholdOptimizer`
      objects that have their constraint set to `'equalized_odds'` this will
      result in a ROC curve plot.
  
      :param threshold_optimizer: the `ThresholdOptimizer` instance for which the
          results should be illustrated.
      :type threshold_optimizer: fairlearn.postprocessing.ThresholdOptimizer
      :param ax: a custom `matplotlib.axes.Axes` object to use for the plots, default None
      :type ax: `matplotlib.axes.Axes`
      :param show_plot: whether or not the generated plot should be shown, default True
      :type show_plot: bool
      """
      try:
          import matplotlib.pyplot as plt
      except ImportError:
          raise RuntimeError(_MATPLOTLIB_IMPORT_ERROR_MESSAGE)
  
      _raise_if_not_threshold_optimizer(threshold_optimizer)
      check_is_fitted(threshold_optimizer)
  
      if ax is None:
          ax = plt.axes()
  
      for (
          sensitive_feature_value
      ) in threshold_optimizer._tradeoff_curve.keys():
          _plot_curve(
              ax,
              sensitive_feature_value,
              "x",
              "y",
              threshold_optimizer._tradeoff_curve[
                  sensitive_feature_value
              ],
          )
  
      if threshold_optimizer.constraints == "equalized_odds":
          _plot_overlap(
              ax,
              threshold_optimizer._x_grid,
              threshold_optimizer._y_min,
          )
          _plot_solution(
              ax,
              threshold_optimizer._x_best,
              threshold_optimizer._y_best,
              "solution",
              "$P[\\hat{Y}=1|Y=0]$",
              "$P[\\hat{Y}=1|Y=1]$",
          )
      else:
          _plot_solution(
              ax,
              threshold_optimizer._x_best,
              None,
              "solution",
              threshold_optimizer.x_metric_,
              threshold_optimizer.y_metric_,
          )
  
      if show_plot:
          plt.show()
  
file_path: fairlearn/fairlearn/postprocessing/_plotting.py
imports: from sklearn.utils.validation import check_is_fitted
  from ._constants import _MATPLOTLIB_IMPORT_ERROR_MESSAGE
  from ._threshold_optimizer import ThresholdOptimizer
label_desc: Use image node_id 6 for calling a global function with example usage: plot_threshold_optimizer(threshold_optimizer, ax, show_plot) without return types