"""Render the complete eligible-state comparison; requires matplotlib 3.10.7.""" import csv from pathlib import Path import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.ticker import PercentFormatter def render(data_file, destination): with open(data_file, newline='', encoding='utf-8') as f: rows = [r for r in csv.DictReader(f) if r['geography'] == 'state'] assert len(rows) == 50 destination = Path(destination) destination.mkdir(parents=True, exist_ok=True) colors = {'output_up_jobs_up':'#267166', 'output_up_jobs_down':'#a55b23', 'output_down_jobs_down':'#5a668a', 'output_up_jobs_unchanged':'#707070'} plt.rcParams.update({'font.family':'DejaVu Sans','font.size':12,'text.color':'#21332b', 'axes.labelcolor':'#21332b','xtick.color':'#4b5d53','ytick.color':'#4b5d53', 'svg.fonttype':'none','svg.hashsalt':'acd-manufacturing-v1', 'figure.facecolor':'#f7f8f0','axes.facecolor':'#f7f8f0'}) for mobile in (False, True): fig, ax = plt.subplots(figsize=(3.6,7.8) if mobile else (10,8)) fig.subplots_adjust(left=.20 if mobile else .12, right=.94, top=.74 if mobile else .79, bottom=.35 if mobile else .25) fig.text(.04,.97,'Manufacturing output\nand jobs across states' if mobile else 'Manufacturing output and jobs across the states', fontsize=16 if mobile else 23, weight='bold', va='top') fig.text(.04,.88 if mobile else .895,'2019–2025 change · All 50 states\nOne dot per state; DC reported separately.' if mobile else '2019–2025 change · All 50 states\nEach dot is one state; DC is reported separately.',fontsize=10.5 if mobile else 13,va='top') ax.axhline(0,color='#6e796e',lw=1);ax.axvline(0,color='#6e796e',lw=1) for row in rows: x,y=float(row['jobs_change_pct']),float(row['real_gdp_change_pct']) ax.scatter(x,y,s=44 if mobile else 65,color=colors[row['direction_group']],edgecolor='white',linewidth=.8,alpha=.9,zorder=3) offsets=({'North Carolina':(-25,-24),'Georgia':(9,-10),'Virginia':(8,4)} if mobile else {'North Carolina':(-105,-30),'Georgia':(35,15),'Virginia':(-105,18)}) if row['state'] in offsets: label={'North Carolina':'NC','Georgia':'GA','Virginia':'VA'}[row['state']] if mobile else row['state'] ax.annotate(label,(x,y),xytext=offsets[row['state']],textcoords='offset points',fontsize=10 if mobile else 12, bbox=dict(facecolor='#f7f8f0',alpha=.9,edgecolor='none',pad=1), arrowprops=dict(arrowstyle='-',color='#66786b',lw=.8),zorder=5) ax.set_xlim(-12,18);ax.set_ylim(-30,44) ax.set_xticks([-10,0,10] if mobile else [-10,-5,0,5,10,15]);ax.set_yticks([-20,0,20,40]) ax.xaxis.set_major_formatter(PercentFormatter(100,decimals=0));ax.yaxis.set_major_formatter(PercentFormatter(100,decimals=0)) ax.set_xlabel('Payroll jobs change',labelpad=10,fontsize=11 if mobile else 12);ax.set_ylabel('Real manufacturing GDP change',labelpad=8,fontsize=11 if mobile else 12) ax.grid(alpha=.13);ax.spines[['top','right']].set_visible(False) labels=[('19 states: output and jobs up','#267166'),('20: output up, jobs down','#a55b23'), ('10: output and jobs down','#5a668a'),('1: output up, jobs unchanged','#707070')] from matplotlib.lines import Line2D fig.legend([Line2D([0],[0],marker='o',color=c,linestyle='') for _,c in labels], [t for t,_ in labels],loc='lower left',bbox_to_anchor=(.01,.14 if mobile else .105),frameon=False, ncol=1 if mobile else 2,fontsize=10 if mobile else 11) footer=('BEA: September 2026 GDP edition.\nBLS: October 2026 file; captured November 20.\nAnnual endpoints; no causal/productivity estimate.\nActually Clean Data calculations\nactuallycleandata.com') if mobile else ( 'Sources: BEA state GDP (September 2026); BLS state CES (October 2026 bulk file, captured November 20).\nAnnual endpoints; not a causal or productivity estimate. Calculations: Actually Clean Data · actuallycleandata.com') fig.text(.04,.025,footer,fontsize=8.5 if mobile else 10,linespacing=1.5) name='manufacturing-output-jobs'+('-mobile' if mobile else '') fig.savefig(destination/(name+'.svg'),metadata={'Date':None,'Creator':'Actually Clean Data; matplotlib 3.10.7'}) if not mobile:fig.savefig(destination/(name+'.png'),dpi=160) plt.close(fig) if __name__ == '__main__': render('state_comparison.csv','figures')