codex/tocopherol-count-feasible-mixtures.py

tocopherol-count-feasible-mixtures.py
"""Feasible tocopherol mole fractions at a normalized aromatic count r=1.30.
Python 3.14 / Matplotlib 3.10. Run in _media for cwd PNG.
The beta/gamma split remains unresolved at every point of the blue segment.
"""
from pathlib import Path
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon

r = 1.30
lo, hi = max(0, r-1), r/2
fig, ax = plt.subplots(figsize=(6.6, 4.5), dpi=100, facecolor='white')
ax.add_patch(Polygon([(0, 0), (1, 0), (0, 1)], facecolor='#eeeeee', edgecolor='#999999'))
ax.plot([lo, hi], [1-r+lo, 1-r+hi], color='#1766a5', linewidth=3)
ax.scatter([lo, hi], [0, 1-r+hi], s=45, color='#1766a5', zorder=3)
ax.annotate(r'$x_\delta=0.30,\ x_\alpha=0$'+'\n'+r'$x_\beta+x_\gamma=0.70$',
            xy=(lo, 0), xytext=(.06, .22), fontsize=10,
            arrowprops=dict(arrowstyle='->', color='#555555'))
ax.annotate(r'$x_\delta=0.65,\ x_\alpha=0.35$'+'\n'+r'$x_\beta+x_\gamma=0$',
            xy=(hi, 1-r+hi), xytext=(.63, .64), fontsize=10,
            arrowprops=dict(arrowstyle='->', color='#555555'))
ax.text(.10, .78, 'Gray: nonnegative fractions\nBlue: identical total count r = 1.30', fontsize=10)
ax.set(xlim=(-.03, 1.05), ylim=(-.03, 1.03), xlabel=r'$x_\delta$', ylabel=r'$x_\alpha$',
       title='Different tocopherol mixtures, one aromatic-proton count')
ax.spines[['top', 'right']].set_visible(False)
ax.set_aspect('equal')
fig.text(.5, .025, r'$x_\alpha=1-r+x_\delta$; remaining fraction is $x_\beta+x_\gamma$',
         ha='center', fontsize=10)
fig.tight_layout(rect=(0, .05, 1, 1))
fig.savefig(Path('tocopherol-count-feasible-mixtures.png'), facecolor='white', dpi=100)
plt.close(fig)