import matplotlib.pyplot as plt
import numpy as np
FACILITY_ID = 2706594
# Bucket columns
amount_cols = [c for c in before.columns if c.startswith('amount_') and not c.startswith('amount_pct')]
labels = [c.replace('amount_', '') for c in amount_cols]
# Extract values
b_vals = before[before['facility_id'] == FACILITY_ID][amount_cols].iloc[0].values / 1e6
a_vals = after[after['facility_id'] == FACILITY_ID][amount_cols].iloc[0].values / 1e6
# Plot
x = np.arange(len(labels))
w = 0.4
fig, ax = plt.subplots(figsize=(14, 5))
ax.bar(x - w/2, b_vals, w, label='Before', color='steelblue')
ax.bar(x + w/2, a_vals, w, label='After', color='coral')
ax.set_xticks(x)
ax.set_xticklabels(labels, rotation=40, ha='right')
ax.set_ylabel('Amount (£M)')
ax.set_title(f'Facility {FACILITY_ID} — Amount Buckets: Before vs After')
ax.legend()
ax.grid(axis='y', linestyle='--', alpha=0.4)
plt.tight_layout()
plt.show()
