codexcoaptation-area-connectivity.py
coaptation-area-connectivity.py
"""Equal contact areas can have different connectivity in a 2D gap map.
Python 3.14 / Matplotlib 3.10. Run in _media; output PNG in cwd.
Both maps are 10 mm squares; each contact strip has area 20 mm^2.
Flow paths are constrained to stay in the square; side boundaries are closed.
"""
from pathlib import Path
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
fig, axes = plt.subplots(1, 2, figsize=(7.0, 3.8), dpi=100, facecolor='white')
for ax in axes:
ax.add_patch(Rectangle((0, 0), 10, 10, facecolor='white', edgecolor='#555555', lw=1.5))
ax.set(xlim=(-.3, 10.3), ylim=(-.3, 10.3), aspect='equal')
ax.axis('off')
axes[0].add_patch(Rectangle((0, 4), 10, 2, color='#555555'))
axes[1].add_patch(Rectangle((4, 0), 2, 10, color='#555555'))
axes[0].annotate('', xy=(2.5, 3.5), xytext=(2.5, .6), arrowprops=dict(arrowstyle='->', color='#bc4b28', lw=2.3))
axes[0].plot(2.5, 3.6, 'x', color='#bc4b28', ms=10, mew=2)
axes[1].annotate('', xy=(2, 9.4), xytext=(2, .6), arrowprops=dict(arrowstyle='->', color='#1766a5', lw=2.3))
axes[0].set_title('Width-spanning contact\nNo bottom-to-top path', fontsize=10)
axes[1].set_title('Height-spanning contact\nOpen side path', fontsize=10)
for ax in axes:
ax.text(.5, -.06, r'Contact area = 20 mm$^2$', ha='center', transform=ax.transAxes, fontsize=10)
fig.suptitle('Equal contact area does not determine gap connectivity', fontsize=12)
fig.text(.5, .035, 'Gray = contact; white = gap. Ideal 2D maps, not patient anatomy or leakage predictions.',
ha='center', fontsize=9)
fig.subplots_adjust(left=.05, right=.95, top=.76, bottom=.18, wspace=.20)
fig.savefig(Path('coaptation-area-connectivity.png'), facecolor='white', dpi=100)
plt.close(fig)