DOC Fix label mismatch in ICA vs. PCA example
@@ -68,12 +68,9 @@ def plot_samples(S, axis_list=None):
S[:, 0], S[:, 1], s=2, marker="o", zorder=10, color="steelblue", alpha=0.5
)
if axis_list is not None:
- colors = ["orange", "red"]
- for color, axis in zip(colors, axis_list):
+ for axis, color, label in axis_list:
axis /= axis.std()
x_axis, y_axis = axis
- # Trick to get legend to work
- plt.plot(0.1 * x_axis, 0.1 * y_axis, linewidth=2, color=color)
plt.quiver(
(0, 0),
(0, 0),
@@ -83,6 +80,7 @@ def plot_samples(S, axis_list=None):
width=0.01,
scale=6,
color=color,
+ label=label,
)
plt.hlines(0, -3, 3)
@@ -98,10 +96,10 @@ plt.subplot(2, 2, 1)
plot_samples(S / S.std())
plt.title("True Independent Sources")
-axis_list = [pca.components_.T, ica.mixing_]
+axis_list = [(pca.components_.T, "orange", "PCA"), (ica.mixing_, "red", "ICA")]
plt.subplot(2, 2, 2)
plot_samples(X / np.std(X), axis_list=axis_list)
-legend = plt.legend(["PCA", "ICA"], loc="upper right")
+legend = plt.legend(loc="lower right")
legend.set_zorder(100)
plt.title("Observations")
