# 図2の下書き: 到達の捕獲面積 σ を I/B に対して（k 別、厚い層と薄い層）。データは各 jsonl から手で拾った値（notes_xsec.md 11節）
import matplotlib; matplotlib.use('Agg')
import matplotlib.pyplot as plt, numpy as np
from matplotlib import font_manager as fm
import os
for fp in ('/mnt/c/Windows/Fonts/YuGothM.ttc',):
    if os.path.exists(fp): fm.fontManager.addfont(fp)
plt.rcParams['font.family']=[fm.FontProperties(fname='/mnt/c/Windows/Fonts/YuGothM.ttc').get_name(),'sans-serif']
fig,ax=plt.subplots(figsize=(6.4,4.6))
data={
 '厚い層 k=16':([4,64],[23.11,378.73],'#1f5fa8','o'),
 '厚い層 k=8（I/B≤64 は種3つの平均、400 は種1つ）':([4,16,64,400],[10.8,26.7,132.0,1212.0],'#4c8fd6','s'),
 '厚い層 k=4':([4,64],[7.5,11.42],'#9cc3ea','^'),
 '薄い層 k=16':([4,16,64],[19.46,40.46,84.36],'#c0392b','o'),
}
for lab,(x,y,c,m) in data.items(): ax.loglog(x,y,marker=m,color=c,lw=2,ms=7,label=lab)
xx=np.array([3,500]); ax.loglog(xx,8*xx/4,'--',color='#555',lw=1); ax.text(200,240,'傾き 1',color='#555',fontsize=9)
ax.loglog(xx,20*np.sqrt(xx/4),':',color='#555',lw=1); ax.text(160,20*np.sqrt(160/4)*0.72,'傾き 0.5',color='#555',fontsize=9)
ax.set_xlabel('灯りと空の明るさの比 I/B（r* = √(I/B) m）'); ax.set_ylabel('わなに入る虫の捕獲面積 σ [m²]')
ax.set_title('反射が速い虫では、厚い層で傾き約1、薄い層で約0.5',fontsize=11)
ax.legend(fontsize=8,frameon=False); ax.grid(True,which='both',alpha=0.2)
fig.tight_layout(); fig.savefig('fig_sigma.png',dpi=140); print('saved')
