"""Render all metros; matplotlib 3.10.7. No jitter or omitted outliers.""" import csv from pathlib import Path import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from matplotlib.lines import Line2D from matplotlib.ticker import PercentFormatter def render(data_file, destination): with open(data_file,newline='',encoding='utf-8') as f:rows=list(csv.DictReader(f)) assert len(rows)==387 destination=Path(destination);destination.mkdir(parents=True,exist_ok=True) 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-metro-jobs-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=.95,top=.73 if mobile else .79,bottom=.32 if mobile else .25) fig.text(.04,.97,'Metro jobs and\nunemployment rates' if mobile else 'Metro jobs and unemployment rates',fontsize=17 if mobile else 24,weight='bold',va='top') fig.text(.04,.88 if mobile else .90,'December 2019 → December 2025\n387 whole metros · seasonally adjusted',fontsize=10.5 if mobile else 13,va='top') ax.axhline(0,color='#78867c',lw=1);ax.axvline(0,color='#78867c',lw=1) for highlight in (False,True): group=[r for r in rows if (r['direction_group']=='jobs_up_rate_up')==highlight] ax.scatter([float(r['jobs_change_pct']) for r in group],[float(r['unemployment_rate_change_pp']) for r in group], s=19 if mobile else 32,c='#267166' if highlight else '#969f9a',alpha=.65,linewidths=.4,edgecolors='white',zorder=3) labels={'39580':('Raleigh',(-42,-24) if mobile else (28,-26)), '16740':('Charlotte',(12,30) if mobile else (32,28)), '12060':('Atlanta',(-48,-28) if mobile else (-72,-34))} for r in rows: if r['area_code'] not in labels:continue name,offset=labels[r['area_code']] ax.annotate(name,(float(r['jobs_change_pct']),float(r['unemployment_rate_change_pp'])),xytext=offset,textcoords='offset points', fontsize=9 if mobile else 11,bbox=dict(facecolor='#f7f8f0',alpha=.95,edgecolor='none',pad=1), arrowprops=dict(arrowstyle='-',color='#66786b',lw=.8),zorder=5) ax.set_xlim(-15,35);ax.set_ylim(-3,3) ax.set_xticks([-10,0,10,20,30]);ax.set_yticks([-2,-1,0,1,2]) ax.xaxis.set_major_formatter(PercentFormatter(100,decimals=0)) ax.set_xlabel('Payroll jobs change',labelpad=9,fontsize=11 if mobile else 12) ax.set_ylabel('Unemployment rate change\n(percentage points)',labelpad=7,fontsize=10 if mobile else 12) ax.grid(alpha=.13);ax.spines[['top','right']].set_visible(False) fig.legend([Line2D([0],[0],marker='o',color=c,linestyle='') for c in ['#267166','#969f9a']], ['209 metros: jobs and rate both up','178: other directions'],loc='lower left',bbox_to_anchor=(.02,.17 if mobile else .12), frameon=False,ncol=1 if mobile else 2,fontsize=10 if mobile else 12) footer=('One dot per metro; dots can overlap.\nBLS CES and LAUS revised histories,\nretained November 20, 2026.\nDescriptive changes, not significance tests.\nActually Clean Data · actuallycleandata.com') if mobile else ( 'One dot per metro; dots can overlap. Workplace jobs and resident unemployment describe different populations.\nSources: BLS CES and LAUS revised histories, retained November 20, 2026. Descriptive changes, not significance tests.\nActually Clean Data calculations · actuallycleandata.com') fig.text(.04,.02,footer,fontsize=8 if mobile else 9,linespacing=1.45) name='metro-jobs-unemployment'+('-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('metro_comparison.csv','figures')