def create_comparison_plot(data, out_loc, y_label, x_label, sort_label, bg_label=None, bg_function=None, settings=None):
    """ Creates a scatter plot comparing multiple trackers between two metric fields, with one on the x-axis and the
    other on the y axis. Adds pareto optical lines and (optionally) a background contour.

    Inputs:
        data: dict of dicts such that data[tracker_name][metric_field_name] = float
        y_label: the metric_field_name to be plotted on the y-axis
        x_label: the metric_field_name to be plotted on the x-axis
        sort_label: the metric_field_name by which trackers are ordered and ranked
        bg_label: the metric_field_name by which (optional) background contours are plotted
        bg_function: the (optional) function bg_function(x,y) which converts the x_label / y_label values into bg_label.
        settings: dict of plot settings with keys:
            'gap_val': gap between axis ticks and bg curves.
            'num_to_plot': maximum number of trackers to plot
    """

    # Only loaded when run to reduce minimum requirements
    from matplotlib import pyplot as plt

    # Get plot settings
    if settings is None:
        gap_val = 2
        num_to_plot = 20
    else:
        gap_val = settings['gap_val']
        num_to_plot = settings['num_to_plot']

    if (bg_label is None) != (bg_function is None):
        raise TrackEvalException('bg_function and bg_label must either be both given or neither given.')

    # Extract data
    tracker_names = np.array(list(data.keys()))
    sort_index = np.array([data[t][sort_label] for t in tracker_names]).argsort()[::-1]
    x_values = np.array([data[t][x_label] for t in tracker_names])[sort_index][:num_to_plot]
    y_values = np.array([data[t][y_label] for t in tracker_names])[sort_index][:num_to_plot]

    # Print info on what is being plotted
    tracker_names = tracker_names[sort_index][:num_to_plot]
    print('\nPlotting %s vs %s, for the following (ordered) trackers:' % (y_label, x_label))
    for i, name in enumerate(tracker_names):
        print('%i: %s' % (i+1, name))

    # Find best fitting boundaries for data
    boundaries = _get_boundaries(x_values, y_values, round_val=gap_val/2)

    fig = plt.figure()

    # Plot background contour
    if bg_function is not None:
        _plot_bg_contour(bg_function, boundaries, gap_val)

    # Plot pareto optimal lines
    _plot_pareto_optimal_lines(x_values, y_values)

    # Plot data points with number labels
    labels = np.arange(len(y_values)) + 1
    plt.plot(x_values, y_values, 'b.', markersize=15)
    for xx, yy, l in zip(x_values, y_values, labels):
        plt.text(xx, yy, str(l), color="red", fontsize=15)

    # Add extra explanatory text to plots
    plt.text(0, -0.11, 'label order:\nHOTA', horizontalalignment='left', verticalalignment='center',
             transform=fig.axes[0].transAxes, color="red", fontsize=12)
    if bg_label is not None:
        plt.text(1, -0.11, 'curve values:\n' + bg_label, horizontalalignment='right', verticalalignment='center',
                 transform=fig.axes[0].transAxes, color="grey", fontsize=12)

    plt.xlabel(x_label, fontsize=15)
    plt.ylabel(y_label, fontsize=15)
    title = y_label + ' vs ' + x_label
    if bg_label is not None:
        title += ' (' + bg_label + ')'
    plt.title(title, fontsize=17)
    plt.xticks(np.arange(0, 100, gap_val))
    plt.yticks(np.arange(0, 100, gap_val))
    min_x, max_x, min_y, max_y = boundaries
    plt.xlim(min_x, max_x)
    plt.ylim(min_y, max_y)
    plt.gca().set_aspect('equal', adjustable='box')
    plt.tight_layout()

    os.makedirs(out_loc, exist_ok=True)
    filename = os.path.join(out_loc, title.replace(' ', '_'))
    plt.savefig(filename + '.pdf', bbox_inches='tight', pad_inches=0.05)
    plt.savefig(filename + '.png', bbox_inches='tight', pad_inches=0.05)
 Creates a scatter plot comparing multiple trackers between two metric fields, with one on the x-axis and the
    other on the y axis. Adds pareto optical lines and (optionally) a background contour.

    Inputs:
        data: dict of dicts such that data[tracker_name][metric_field_name] = float
        y_label: the metric_field_name to be plotted on the y-axis
        x_label: the metric_field_name to be plotted on the x-axis
        sort_label: the metric_field_name by which trackers are ordered and ranked
        bg_label: the metric_field_name by which (optional) background contours are plotted
        bg_function: the (optional) function bg_function(x,y) which converts the x_label / y_label values into bg_label.
        settings: dict of plot settings with keys:
            'gap_val': gap between axis ticks and bg curves.
            'num_to_plot': maximum number of trackers to plot
    
trackeval/plotting.py