Update modules/ui.py
Browse files- modules/ui.py +11 -4
modules/ui.py
CHANGED
@@ -192,12 +192,19 @@ def display_student_progress(username, lang_code='es'):
|
|
192 |
print("labels:", df['label'].tolist())
|
193 |
|
194 |
# Generar el treemap
|
195 |
-
|
|
|
|
|
|
|
|
|
196 |
|
197 |
# Añadir etiquetas manualmente
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
201 |
|
202 |
plt.title('Treemap del total de palabras por categoria gramátical')
|
203 |
plt.axis('off')
|
|
|
192 |
print("labels:", df['label'].tolist())
|
193 |
|
194 |
# Generar el treemap
|
195 |
+
squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
|
196 |
+
|
197 |
+
# Ajustar las etiquetas
|
198 |
+
for text in ax.texts:
|
199 |
+
text.set_visible(False)
|
200 |
|
201 |
# Añadir etiquetas manualmente
|
202 |
+
norm = plt.Normalize(df['count'].min(), df['count'].max())
|
203 |
+
for rect, label in zip(ax.patches, df['label']):
|
204 |
+
x = rect.get_x() + rect.get_width()/2
|
205 |
+
y = rect.get_y() + rect.get_height()/2
|
206 |
+
size = norm(rect.get_height() * rect.get_width())
|
207 |
+
ax.text(x, y, label, ha='center', va='center', fontsize=8+size*10)
|
208 |
|
209 |
plt.title('Treemap del total de palabras por categoria gramátical')
|
210 |
plt.axis('off')
|