Skip to content

Commit 16b0045

Browse files
committed
optional code to customize markers with images
1 parent c2c1bfa commit 16b0045

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

notebooks/Eval/ASR_eval.ipynb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@
657657
},
658658
{
659659
"cell_type": "code",
660-
"execution_count": 65,
660+
"execution_count": null,
661661
"id": "a11013dc",
662662
"metadata": {},
663663
"outputs": [
@@ -819,6 +819,10 @@
819819
"}\n",
820820
"SHOW_MAX_REGRESSION_ARROW = True\n",
821821
"\n",
822+
"# optionally customize markers (e.g., with a flag) by providing a map from native-language to file path\n",
823+
"from matplotlib.offsetbox import OffsetImage, AnnotationBbox\n",
824+
"IMAGES: dict[str, str] = {}\n",
825+
"\n",
822826
"for dataset, df_d in results.groupby('dataset'): \n",
823827
" # outliers\n",
824828
" df_d = df_d[(df_d[\"cer\"] <= 1) & (df_d[\"wer\"] <= 1)] # drop outliers\n",
@@ -916,6 +920,17 @@
916920
" (df_plot['wer_mean'] + df_plot['wer_std']) * 100, # type: ignore\n",
917921
" color=wer_line.get_color(), alpha=0.2\n",
918922
" )\n",
923+
" if top_lang in IMAGES:\n",
924+
" im = plt.imread(IMAGES[top_lang]) # type: ignore\n",
925+
" img = OffsetImage(im, zoom=15 / im.shape[0]) # tweak zoom to match marker size\n",
926+
" for x, y in zip(df_plot['release_date'], df_plot['wer_mean'] * 100):\n",
927+
" ab = AnnotationBbox(\n",
928+
" img,\n",
929+
" (x, y),\n",
930+
" frameon=False,\n",
931+
" box_alignment=(0.5, 0.5)\n",
932+
" )\n",
933+
" plt.gca().add_artist(ab)\n",
919934
" if INCLUDE_CER:\n",
920935
" cer_line, = plt.plot(df_plot['release_date'], df_plot['cer_mean'] * 100, '-s', color=CER_COLOR, label=f'CER ({top_lang})')\n",
921936
" plt.fill_between(\n",

0 commit comments

Comments
 (0)