"""Transcribe Cui et al., ICCV 2023 Table2; no new estimates or uncertainty."""
from pathlib import Path
import csv
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
p=Path(__file__); rows=list(csv.DictReader(p.with_suffix('.csv').open()))
plt.rcParams.update({'font.family':'DejaVu Sans','font.size':17,'svg.fonttype':'none','svg.hashsalt':'sportsbrain-player-tracking-context-v1'})
fig,ax=plt.subplots(figsize=(6,5.5))
labels=[x['sport'] for x in rows];values=[float(x['mean_annotated_player_boxes_per_frame']) for x in rows]
ax.barh(labels,values,color='#235b73',height=.55);ax.invert_yaxis();ax.set_xlim(0,15)
for i,v in enumerate(values):ax.text(v+.3,i,f'{v:.1f}',va='center',fontsize=18)
ax.set_xlabel('Mean annotated player boxes\nper frame',labelpad=10);ax.set_xticks([0,5,10,15]);ax.spines[['top','right','left']].set_visible(False);ax.tick_params(axis='y',length=0,pad=12)
fig.suptitle('SportsMOT (2023)\nRecording context by sport',fontsize=19,x=.04,ha='left',y=.98)

fig.subplots_adjust(left=.34,right=.88,top=.74,bottom=.26)

fig.savefig(p.with_suffix('.svg'),metadata={'Date':None,'Creator':'Adrian Dunkley; matplotlib'});fig.savefig(p.with_suffix('.png'),dpi=100);plt.close(fig)
