AIdeaText commited on
Commit
8ad32f8
1 Parent(s): 8d5b116

Update modules/ui.py

Browse files
Files changed (1) hide show
  1. 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
- rects = squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
 
 
 
 
196
 
197
  # Añadir etiquetas manualmente
198
- for r, label in zip(rects, df['label']):
199
- x, y, dx, dy = r['x'], r['y'], r['dx'], r['dy']
200
- ax.text(x + dx/2, y + dy/2, label, ha='center', va='center', wrap=True)
 
 
 
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')