"""Exact stoichiometric bounds for two gamma-chain slots per assembly. Python 3.14, NumPy 2.3.5, Matplotlib 3.10.7. Run in _media; writes cwd PNG. This is a constructed counting model, not observed hemoglobin pairing data. """ from pathlib import Path import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np p = np.linspace(0, 1, 501) lower, upper = np.maximum(0, 2*p-1), p assert np.all(p*p >= lower-1e-12) and np.all(p*p <= upper+1e-12) fig, ax = plt.subplots(figsize=(8, 5), dpi=100, facecolor='white') ax.fill_between(p, lower, upper, color='#dbeaf2', label='All feasible pairings') ax.plot(p, upper, color='#286789', lw=2, label=r'Upper bound: $x=p$') ax.plot(p, lower, color='#286789', lw=2) ax.plot(p, p*p, '--', color='#a0472d', lw=2, label=r'Independent placement: $x=p^2$') ax.vlines(.6, .2, .6, color='#373e45', lw=2.5) ax.plot([.6, .6], [.2, .6], 'o', color='#373e45', ms=6) ax.plot(.6, .36, 'o', color='#a0472d', ms=7, zorder=5) ax.annotate(r'$p=0.60$: $0.20\leq x\leq0.60$', xy=(.6, .6), xytext=(.12, .82), fontsize=11, arrowprops=dict(arrowstyle='->', color='#373e45')) ax.annotate('Independent value = 0.36', xy=(.6, .36), xytext=(.62, .12), fontsize=9, arrowprops=dict(arrowstyle='->', color='#a0472d'), color='#8c3a24') ax.text(.73, .66, r'$x\geq2p-1$', fontsize=11, rotation=50, color='#286789') ax.set(xlim=(0, 1), ylim=(0, 1), xlabel='G-gamma fraction among all gamma chains, p', ylabel='Fraction of tetramers with two G-gamma chains, x') ax.set_aspect('equal', adjustable='box') ax.spines[['top', 'right']].set_visible(False) ax.grid(alpha=.18) ax.legend(loc='upper left', bbox_to_anchor=(1.02, 1.0), frameon=False, fontsize=9) fig.suptitle('Bulk chain composition does not determine pairing', fontsize=13) fig.text(.5, .025, 'Assumptions: two gamma chains per tetramer; only G-gamma and A-gamma forms.', ha='center', fontsize=9) fig.subplots_adjust(left=.12, right=.66, bottom=.16, top=.89) fig.savefig(Path('gamma-chain-pairing-feasible-region.png'), dpi=100, facecolor='white') plt.close(fig)