Update modules/ui.py
Browse files- modules/ui.py +8 -2
modules/ui.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
# modules/ui.py
|
2 |
# Importaciones estandar de python
|
3 |
import streamlit as st
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
import matplotlib
|
6 |
matplotlib.use('Agg')
|
|
|
7 |
import squarify
|
8 |
import pandas as pd
|
9 |
from datetime import datetime
|
@@ -186,13 +186,19 @@ def display_student_progress(username, lang_code='es'):
|
|
186 |
print("student_data['word_count']:", student_data['word_count'])
|
187 |
print("df:", df)
|
188 |
|
189 |
-
fig, ax = plt.subplots(figsize=(8, 6), dpi=
|
190 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
191 |
print("colors:", colors)
|
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:
|
|
|
1 |
# modules/ui.py
|
2 |
# Importaciones estandar de python
|
3 |
import streamlit as st
|
|
|
4 |
import matplotlib
|
5 |
matplotlib.use('Agg')
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
import squarify
|
8 |
import pandas as pd
|
9 |
from datetime import datetime
|
|
|
186 |
print("student_data['word_count']:", student_data['word_count'])
|
187 |
print("df:", df)
|
188 |
|
189 |
+
fig, ax = plt.subplots(figsize=(8, 6), dpi=30)
|
190 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
191 |
print("colors:", colors)
|
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 |
+
# Después de crear la figura
|
198 |
+
buf = io.BytesIO()
|
199 |
+
fig.savefig(buf, format='png')
|
200 |
+
buf.seek(0)
|
201 |
+
st.image(buf, use_column_width=True)
|
202 |
|
203 |
# Ajustar las etiquetas
|
204 |
for text in ax.texts:
|