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

Update modules/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui.py +5 -4
modules/ui.py CHANGED
@@ -191,12 +191,13 @@ def display_student_progress(username, lang_code='es'):
191
  print("colors:", colors)
192
  print("labels:", df['label'].tolist())
193
 
194
- # Corrección en la función squarify.plot
195
- squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
196
 
197
  # Añadir etiquetas manualmente
198
- for i, (x, y, dx, dy) in enumerate(zip(ax.patches[0].get_xy(), ax.patches[0].get_width(), ax.patches[0].get_height())):
199
- ax.text(x + dx/2, y + dy/2, df['label'].iloc[i], ha='center', va='center')
 
200
 
201
  plt.title('Treemap del total de palabras por categoria gramátical')
202
  plt.axis('off')
 
191
  print("colors:", colors)
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')