mpl.rcParams['mathtext.fontset'] = 'cm'
mpl.rcParams['mathtext.rm'] = 'serif'
import matplotlib.pyplot as plt


def label_diff_x(ax, x0, x1, y, cap_size, y_text, text):
    xmid = x0 + ((x1 - x0) / 2)
    ax.plot([x0, x0, x1, x1], [y - cap_size, y, y, y - cap_size], color='black', lw=1)
    #
    ax.annotate(text, xy=(xmid, y), xytext=(xmid, y_text), zorder=10, ha='center', va='center', fontsize='medium')
