def METHOD_NAME(x_log, y_log, expected_slope, field_str, save_plot):
    slope_rtol = 0.2
    slope, intercept, r_value, p_value, std_err = stats.linregress(x_log, y_log)
    if save_plot:
        import matplotlib.pyplot as plt
        fig, ax = plt.subplots(figsize=(5, 5))
        # plot points
        ax.plot(x_log, y_log, 'k.')
        x_min = x_log.min()
        x_max = x_log.max()
        offset = 0.05*(x_max - x_min)
        n = 50
        xx = numpy.linspace(x_min - offset, x_max + offset, n)
        yy = intercept + slope*xx
        # plot line
        ax.plot(xx, yy, linestyle='--', linewidth=0.5, color='k')
        ax.text(xx[2*n/3], yy[2*n/3], '{:4.2f}'.format(slope),
                verticalalignment='top',
                horizontalalignment='left')
        ax.set_xlabel('log10(dx)')
        ax.set_ylabel('log10(L2 error)')
        ax.set_title(field_str)
        ref_str = 'ref-' + '-'.join([str(r) for r in ref_list])
        imgfile = '_'.join(['convergence', setup_name, field_str, ref_str, fs_type])
        imgfile += '.png'
        img_dir = create_directory('plots')
        imgfile = os.path.join(img_dir, imgfile)
        print_output('saving figure {:}'.format(imgfile))
        plt.savefig(imgfile, dpi=200, bbox_inches='tight')
    if expected_slope is not None:
        err_msg = '{:}: Wrong convergence rate {:.4f}, expected {:.4f}'.format(setup_name, slope, expected_slope)
        assert abs(slope - expected_slope)/expected_slope < slope_rtol, err_msg
        print_output('{:}: convergence rate {:.4f} PASSED'.format(setup_name, slope))
    else:
        print_output('{:}: {:} convergence rate {:.4f}'.format(setup_name, field_str, slope))
    return slope