+--  9 lines: import pandas as pd----------------------------------------------

+--  2 lines: def chunked(iterable, n):----------------------------------------

substances = 'H2', 'O2', 'N2', 'D2', 'paraH2'

kwargs = dict(
    names=('run', '', 'lbda', 'cnt'),
    usecols=[0, 2, 3],
    index_col=('run', 'lbda'),
    sep='\t',
    decimal=',')

+-- 10 lines: def corrected_spectrum(substance):-------------------------------

+-- 23 lines: def find_cauchy_peaks(x, y, guesses, gamma=1):-------------------


fig, axs = plt.subplots(nrows=len(substances), figsize=(4, 8))

guesses = {
    'H2': (543, 550, 557, 564),
    'O2': (581,),
    'N2': (550, 608),
    'D2': (542, 545, 548, 551),
    'paraH2': (543, 557)
}


plt.rc('text', usetex=True)
plt.rc('font', family='serif')

plt.

for substance, ax in zip(substances, axs):
    data = corrected_spectrum(substance)

    x = data.index.values
    y = data.cnt.values
    ax.step(x, y, 'k', zorder=-10)
    ax.set_ylim(0, None)

    peaks = find_cauchy_peaks(x, y, guesses[substance])

    for mu, gamma, A in peaks:
        l, r = mu - gamma, mu + gamma
        ax.axvspan(l, r, color='C1', alpha=.2)
        ax.vlines(mu, 0, A, color='C1', lw=3)
        ax.hlines(A/2, l, r, color='C1')

    ax.set_title(substance, y=1.0, loc='right', pad=-14)
    ax.get_yaxis().set_visible(False)

ax.set_xlabel('$\\lambda$ / nm')

plt.show()