def METHOD_NAME(x_log, y_log, expected_slope, field_str, saveplot, ax):
    slope_rtol = 0.07
    slope, intercept, r_value, p_value, std_err = stats.linregress(x_log, y_log)
    if saveplot:
        # 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)
        npoints = 50
        xx = numpy.linspace(x_min - offset, x_max + offset, npoints)
        yy = intercept + slope*xx
        # plot line
        ax.plot(xx, yy, linestyle='--', linewidth=0.5, color='k')
        ax.text(xx[2*int(npoints/3)], yy[2*int(npoints/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)
    if expected_slope is not None:
        err_msg = '{:}: Wrong {:} convergence rate {:.4f}, expected {:.4f}'.format(setup_name, field_str, slope, expected_slope)
        assert slope > expected_slope*(1 - slope_rtol), err_msg
        print_output('{:}: {:} convergence rate {:.4f} PASSED'.format(setup_name, field_str, slope))
    else:
        print_output('{:}: {:} convergence rate {:.4f}'.format(setup_name, field_str, slope))
    return slope