code: def _fit_and_plot(constraints, plotting_data):
      import matplotlib.pyplot as plt
  
      adjusted_predictor = ThresholdOptimizer(
          estimator=ExamplePredictor(scores_ex),
          constraints=constraints,
          predict_method="predict",
      )
      adjusted_predictor.fit(
          plotting_data.X,
          plotting_data.y,
          sensitive_features=plotting_data.sensitive_features,
      )
      fig, (ax) = plt.subplots(1, 1)
      plot_threshold_optimizer(
          adjusted_predictor, ax=ax, show_plot=False
      )
      return fig
  
file_path: fairlearn/test/unit/postprocessing/test_plots.py
imports: from importlib.metadata import PackageNotFoundError
  import pytest
  from fairlearn.postprocessing import ThresholdOptimizer, plot_threshold_optimizer
  from .conftest import ExamplePredictor, _data_ex1, _data_ex2, _data_ex3, scores_ex
label_desc: Use image node_id 1 for calling a global function with example usage: _fit_and_plot(constraints, plotting_data) and returns: fig