"""Fig. 3 (SER gain vs relevance coefficient) regenerated with the SAME box aspect (0.8) as the Fig. 2 panels, from results/data/beta_sweep.csv.""" import csv, numpy as np import matplotlib; matplotlib.use('Agg') import matplotlib.pyplot as plt rows = list(csv.DictReader(open('results/data/beta_sweep.csv'))) SNRS = [0.0, 5.0, 10.0] STY = {0.0: ('#C62828', 's--', 'SNR = 0 dB'), 5.0: ('#E65100', '^-.', 'SNR = 5 dB'), 10.0: ('#1565C0', 'o-', 'SNR = 10 dB')} FILL = {0.0: '#C62828', 5.0: '#E65100', 10.0: '#1565C0'} data = {s: {'b': [], 'g': []} for s in SNRS} for r in rows: s = float(r['snr_label']) if s in data: data[s]['b'].append(float(r['beta_sq'])); data[s]['g'].append(float(r['gain_maml'])) for s in SNRS: o = np.argsort(data[s]['b']) data[s]['b'] = np.array(data[s]['b'])[o]; data[s]['g'] = np.array(data[s]['g'])[o] fig, ax = plt.subplots(figsize=(5.2, 4.6)) for s in SNRS: c, mk, lbl = STY[s] ax.plot(data[s]['b'], data[s]['g'], mk, lw=2.0, color=c, label=lbl, markersize=5) ax.fill_between(data[s]['b'], 0, data[s]['g'], alpha=0.07, color=FILL[s]) ax.axhline(0, color='gray', lw=0.8, ls=':') ax.set_xlabel(r'Semantic relevance coefficient $\beta_{u,v}=\beta_u\cdot\beta_v$', fontsize=13) ax.set_ylabel('SER gain over OFDMA', fontsize=13) ax.tick_params(labelsize=12) ax.legend(loc='upper left', fontsize=12) ax.grid(True, alpha=0.3) ax.set_xlim(-0.01, 0.82) ax.set_box_aspect(0.8) # match the Fig. 2 panel box aspect fig.tight_layout() fig.savefig('results/fig4_beta_sweep.pdf', bbox_inches='tight') fig.savefig('results/fig4_beta_sweep.png', dpi=150, bbox_inches='tight') print('saved results/fig4_beta_sweep.pdf (box_aspect=0.8)')