|
657 | 657 | }, |
658 | 658 | { |
659 | 659 | "cell_type": "code", |
660 | | - "execution_count": 65, |
| 660 | + "execution_count": null, |
661 | 661 | "id": "a11013dc", |
662 | 662 | "metadata": {}, |
663 | 663 | "outputs": [ |
|
819 | 819 | "}\n", |
820 | 820 | "SHOW_MAX_REGRESSION_ARROW = True\n", |
821 | 821 | "\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", |
822 | 826 | "for dataset, df_d in results.groupby('dataset'): \n", |
823 | 827 | " # outliers\n", |
824 | 828 | " df_d = df_d[(df_d[\"cer\"] <= 1) & (df_d[\"wer\"] <= 1)] # drop outliers\n", |
|
916 | 920 | " (df_plot['wer_mean'] + df_plot['wer_std']) * 100, # type: ignore\n", |
917 | 921 | " color=wer_line.get_color(), alpha=0.2\n", |
918 | 922 | " )\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", |
919 | 934 | " if INCLUDE_CER:\n", |
920 | 935 | " cer_line, = plt.plot(df_plot['release_date'], df_plot['cer_mean'] * 100, '-s', color=CER_COLOR, label=f'CER ({top_lang})')\n", |
921 | 936 | " plt.fill_between(\n", |
|
0 commit comments