Update functions.py
Browse files- functions.py +4 -0
functions.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
|
|
| 1 |
import json
|
| 2 |
import requests
|
|
|
|
| 3 |
from datasets import load_dataset
|
| 4 |
|
| 5 |
# Cargar modalidades y tareas (ahora devuelve una lista de tareas) <button class="citation-flag" data-index="1">
|
|
@@ -59,6 +61,7 @@ def generar_grafica_barras(tareas_seleccionadas, MODALIDAD_TAREAS):
|
|
| 59 |
tareas_modalidad = datos["tareas"].keys()
|
| 60 |
conteo[modalidad] = len([t for t in tareas_seleccionadas if t in tareas_modalidad])
|
| 61 |
|
|
|
|
| 62 |
fig, ax = plt.subplots(figsize=(10, 6))
|
| 63 |
ax.barh(list(conteo.keys()), list(conteo.values()), color='skyblue')
|
| 64 |
ax.set_xlabel('Cantidad de Tareas Seleccionadas')
|
|
@@ -66,6 +69,7 @@ def generar_grafica_barras(tareas_seleccionadas, MODALIDAD_TAREAS):
|
|
| 66 |
ax.set_title('Distribuci贸n de Tareas por Modalidad')
|
| 67 |
ax.invert_yaxis()
|
| 68 |
return fig
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
raise ValueError(f"Error al generar gr谩fica: {str(e)}")
|
| 71 |
|
|
|
|
| 1 |
+
# functions.py
|
| 2 |
import json
|
| 3 |
import requests
|
| 4 |
+
import matplotlib.pyplot as plt # A帽adido import <button class="citation-flag" data-index="1">
|
| 5 |
from datasets import load_dataset
|
| 6 |
|
| 7 |
# Cargar modalidades y tareas (ahora devuelve una lista de tareas) <button class="citation-flag" data-index="1">
|
|
|
|
| 61 |
tareas_modalidad = datos["tareas"].keys()
|
| 62 |
conteo[modalidad] = len([t for t in tareas_seleccionadas if t in tareas_modalidad])
|
| 63 |
|
| 64 |
+
# Crear gr谩fica con matplotlib
|
| 65 |
fig, ax = plt.subplots(figsize=(10, 6))
|
| 66 |
ax.barh(list(conteo.keys()), list(conteo.values()), color='skyblue')
|
| 67 |
ax.set_xlabel('Cantidad de Tareas Seleccionadas')
|
|
|
|
| 69 |
ax.set_title('Distribuci贸n de Tareas por Modalidad')
|
| 70 |
ax.invert_yaxis()
|
| 71 |
return fig
|
| 72 |
+
|
| 73 |
except Exception as e:
|
| 74 |
raise ValueError(f"Error al generar gr谩fica: {str(e)}")
|
| 75 |
|