Browse Source

[DATALAD] Recorded changes

Lucas Gautheron 1 month ago
parent
commit
fbcb62f486
1 changed files with 23 additions and 0 deletions
  1. 23 0
      code/plots/algo_comparison.py

+ 23 - 0
code/plots/algo_comparison.py

@@ -75,6 +75,18 @@ def algo_comparison(algo1, algo2, algo1_name, algo2_name):
         for col in range(2):
             i = row + 2 * col
 
+            age = np.array([algo1["age"][k - 1] for k in algo1["children"]])
+            
+            if speakers[i] in ["CHI", "FEM"]:
+                x1, x2, y1, y2 = 400, 4000, 400, 4000
+
+                axins = axes[row, col].inset_axes(
+                    [0.57, 0.06, 0.4, 0.4],
+                    xlim=(x1, x2), ylim=(y1, y2), xticklabels=[], yticklabels=[])
+                axins.set_xlim(x1, x2)
+                axins.set_ylim(y1, y2)
+                axes[row,col].indicate_inset_zoom(axins, edgecolor="black")
+
             for corpus in set(algo1["corpus"]):
                 mask = np.array([algo1["corpus"][k - 1] == corpus for k in algo1["children"]])
                 vocs_algo1 = algo1["vocs"][mask,i]
@@ -85,8 +97,18 @@ def algo_comparison(algo1, algo2, algo1_name, algo2_name):
                     vocs_algo2,
                     s=0.5,
                     color=cb_colors[corpus - 1],
+                    alpha=0.9*np.clip(age[mask], 0, 36)/36
                 )
 
+                if speakers[i] in ["CHI", "FEM"]:
+                    axins.scatter(
+                        vocs_algo1,
+                        vocs_algo2,
+                        s=0.5,
+                        color=cb_colors[corpus - 1],
+                        alpha=0.9*np.clip(age[mask], 0, 36)/36
+                    )
+
             if row == 1 and col == 0:
                 axes[row, col].set_xlabel(algo1_name)
                 axes[row, col].set_ylabel(algo2_name)
@@ -102,5 +124,6 @@ def algo_comparison(algo1, algo2, algo1_name, algo2_name):
 
     plt.subplots_adjust(wspace=0, hspace=0)
     fig.savefig(f"output/algo_comparison_{algo1_name}_{algo2_name}.eps", bbox_inches="tight")
+    fig.savefig(f"output/algo_comparison_{algo1_name}_{algo2_name}.pdf", bbox_inches="tight")
 
 algo_comparison(data["lena"], data["vtc"], "LENA", "VTC")