Update my_pages/ica.py
Browse files- my_pages/ica.py +22 -3
my_pages/ica.py
CHANGED
|
@@ -77,18 +77,37 @@ def render():
|
|
| 77 |
# Plot
|
| 78 |
fig, ax = plt.subplots()
|
| 79 |
ax.plot(*np.append(vertices, [vertices[0]], axis=0).T)
|
| 80 |
-
ax.scatter(vertices[:,0], vertices[:,1], c=["blue", "green", "red"], s=100)
|
| 81 |
ax.text(*vertices[0], "Intentional", ha="center", va="bottom")
|
| 82 |
ax.text(*vertices[1], "Conventional", ha="right", va="top")
|
| 83 |
ax.text(*vertices[2], "Arbitrary", ha="left", va="top")
|
| 84 |
-
ax.scatter(point[0], point[1], c="white", s=
|
| 85 |
-
ax.scatter(point[0], point[1], c="orange", s=
|
| 86 |
ax.set_aspect("equal")
|
| 87 |
ax.axis("off")
|
| 88 |
|
| 89 |
fig.patch.set_alpha(0)
|
| 90 |
ax.patch.set_alpha(0)
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
st.pyplot(fig)
|
| 93 |
|
| 94 |
# Display interpretation
|
|
|
|
| 77 |
# Plot
|
| 78 |
fig, ax = plt.subplots()
|
| 79 |
ax.plot(*np.append(vertices, [vertices[0]], axis=0).T)
|
| 80 |
+
# ax.scatter(vertices[:,0], vertices[:,1], c=["blue", "green", "red"], s=100)
|
| 81 |
ax.text(*vertices[0], "Intentional", ha="center", va="bottom")
|
| 82 |
ax.text(*vertices[1], "Conventional", ha="right", va="top")
|
| 83 |
ax.text(*vertices[2], "Arbitrary", ha="left", va="top")
|
| 84 |
+
ax.scatter(point[0], point[1], c="white", s=20000)
|
| 85 |
+
ax.scatter(point[0], point[1], c="orange", s=20000, zorder=5, alpha=0.3)
|
| 86 |
ax.set_aspect("equal")
|
| 87 |
ax.axis("off")
|
| 88 |
|
| 89 |
fig.patch.set_alpha(0)
|
| 90 |
ax.patch.set_alpha(0)
|
| 91 |
|
| 92 |
+
# --- Dummy points scattered inside triangle ---
|
| 93 |
+
# (x, y, text)
|
| 94 |
+
locations = [
|
| 95 |
+
(0.3, 0.2, "Example A"),
|
| 96 |
+
(0.7, 0.25, "Example B"),
|
| 97 |
+
(0.5, 0.6, "Example C"),
|
| 98 |
+
(0.2, 0.4, "Example D"),
|
| 99 |
+
(0.8, 0.5, "Example E"),
|
| 100 |
+
]
|
| 101 |
+
|
| 102 |
+
torch_radius = 0.25 # how far the "torch" illuminates
|
| 103 |
+
|
| 104 |
+
# Illuminate nearby points
|
| 105 |
+
for (x, y, label) in locations:
|
| 106 |
+
dist = np.linalg.norm([x - point[0], y - point[1]])
|
| 107 |
+
if dist <= torch_radius:
|
| 108 |
+
ax.scatter(x, y, c="red", s=50, zorder=6)
|
| 109 |
+
ax.text(x, y + 0.03, label, ha="center", va="bottom", color="white")
|
| 110 |
+
|
| 111 |
st.pyplot(fig)
|
| 112 |
|
| 113 |
# Display interpretation
|