AIdeaText commited on
Commit
ec72822
·
verified ·
1 Parent(s): 2fc209b

Update modules/ui.py

Browse files
Files changed (1) hide show
  1. modules/ui.py +29 -29
modules/ui.py CHANGED
@@ -171,35 +171,35 @@ def display_student_progress(username, lang_code='es'):
171
  st.title(f"Progreso de {username}")
172
 
173
  if student_data['word_count']:
174
- st.subheader("Total de palabras por categoria gramatical")
175
-
176
- df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
177
- df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
178
-
179
- fig, ax = plt.subplots(figsize=(8, 6), dpi=100) # Tamaño reducido
180
- colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
181
-
182
- squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
183
-
184
- for text in ax.texts:
185
- text.set_visible(False)
186
-
187
- norm = plt.Normalize(df['count'].min(), df['count'].max())
188
- for rect, label in zip(ax.patches, df['label']):
189
- x = rect.get_x() + rect.get_width()/2
190
- y = rect.get_y() + rect.get_height()/2
191
- size = norm(rect.get_height() * rect.get_width())
192
- ax.text(x, y, label, ha='center', va='center', fontsize=6+size*8) # Tamaño de fuente reducido
193
-
194
- plt.title('Treemap del total de palabras por categoria gramátical')
195
- plt.axis('off')
196
-
197
- buf = io.BytesIO()
198
- fig.savefig(buf, format='png')
199
- buf.seek(0)
200
- st.image(buf, use_column_width=True)
201
- else:
202
- st.info("No hay datos de conteo de palabras disponibles.")
203
 
204
  ############################################# Diagramas de Arco (consolidados)#####################################################################3
205
  st.header("Diagramas de Arco")
 
171
  st.title(f"Progreso de {username}")
172
 
173
  if student_data['word_count']:
174
+ st.subheader("Total de palabras por categoria gramatical")
175
+
176
+ df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
177
+ df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
178
+
179
+ fig, ax = plt.subplots(figsize=(8, 6), dpi=100) # Tamaño reducido
180
+ colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
181
+
182
+ squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax)
183
+
184
+ for text in ax.texts:
185
+ text.set_visible(False)
186
+
187
+ norm = plt.Normalize(df['count'].min(), df['count'].max())
188
+ for rect, label in zip(ax.patches, df['label']):
189
+ x = rect.get_x() + rect.get_width()/2
190
+ y = rect.get_y() + rect.get_height()/2
191
+ size = norm(rect.get_height() * rect.get_width())
192
+ ax.text(x, y, label, ha='center', va='center', fontsize=6+size*8) # Tamaño de fuente reducido
193
+
194
+ plt.title('Treemap del total de palabras por categoria gramátical')
195
+ plt.axis('off')
196
+
197
+ buf = io.BytesIO()
198
+ fig.savefig(buf, format='png')
199
+ buf.seek(0)
200
+ st.image(buf, use_column_width=True)
201
+ else:
202
+ st.info("No hay datos de conteo de palabras disponibles.")
203
 
204
  ############################################# Diagramas de Arco (consolidados)#####################################################################3
205
  st.header("Diagramas de Arco")