import pyfar as pf
import matplotlib.pyplot as plt

# impulse to be filtered
impulse = pf.signals.impulse(256)

orders = [1, 2]
labels = ['First order', 'Second order']

fig, (ax1, ax2) = plt.subplots(2,1, layout='constrained')

for (order, label) in zip(orders, labels):
    # create and apply allpass filter
    sig_filt = pf.dsp.filter.allpass(impulse, 1000, order)
    pf.plot.group_delay(sig_filt, unit='samples', label=label, ax=ax1)
    pf.plot.phase(sig_filt, label=label, ax=ax2, unwrap = True)

ax1.set_title('1. and 2. order allpass filter with fc = 1000 Hz')
ax2.legend()