Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -336,18 +336,18 @@ def plotar_evolucao_bimestres(disciplinas_dados: List[Dict], temp_dir: str,
|
|
336 |
bimestres_deslocados = [bim + desloc for bim in bimestres]
|
337 |
|
338 |
if notas_validas:
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
|
349 |
-
|
350 |
-
|
351 |
|
352 |
for bim, nota in zip(bimestres_deslocados, notas_validas):
|
353 |
if nota is not None:
|
@@ -355,43 +355,44 @@ def plotar_evolucao_bimestres(disciplinas_dados: List[Dict], temp_dir: str,
|
|
355 |
while any(abs(y - (nota + y_offset/20)) < 0.4 for y, _ in anotacoes_usadas.get(bim, [])):
|
356 |
y_offset += 5
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
|
371 |
if bim not in anotacoes_usadas:
|
372 |
anotacoes_usadas[bim] = []
|
373 |
anotacoes_usadas[bim].append((nota + y_offset/20, nota))
|
374 |
|
375 |
titulo_grafico = titulo or 'Evolução das Médias por Disciplina'
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
|
380 |
ax.spines['top'].set_visible(False)
|
381 |
ax.spines['right'].set_visible(False)
|
382 |
|
383 |
-
|
384 |
-
|
|
|
385 |
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
|
390 |
if n_disciplinas > 8:
|
391 |
-
|
392 |
-
|
393 |
else:
|
394 |
-
|
395 |
|
396 |
plt.tight_layout()
|
397 |
|
@@ -401,10 +402,11 @@ def plotar_evolucao_bimestres(disciplinas_dados: List[Dict], temp_dir: str,
|
|
401 |
# Salvar com alta qualidade
|
402 |
nome_arquivo = nome_arquivo or 'evolucao_notas.png'
|
403 |
plot_path = os.path.join(temp_dir, nome_arquivo)
|
404 |
-
|
405 |
-
plt.close()
|
406 |
|
407 |
return plot_path
|
|
|
408 |
def plotar_graficos_destacados(disciplinas_dados: List[Dict], temp_dir: str) -> str:
|
409 |
"""Plota gráficos de médias e frequências com visual aprimorado."""
|
410 |
n_disciplinas = len(disciplinas_dados)
|
|
|
336 |
bimestres_deslocados = [bim + desloc for bim in bimestres]
|
337 |
|
338 |
if notas_validas:
|
339 |
+
ax.plot(bimestres_deslocados, notas_validas,
|
340 |
+
color=cores[idx % len(cores)],
|
341 |
+
marker=marcadores[idx % len(marcadores)],
|
342 |
+
markersize=8,
|
343 |
+
linewidth=2.5,
|
344 |
+
label=disc_data['disciplina'],
|
345 |
+
linestyle=estilos_linha[idx % len(estilos_linha)],
|
346 |
+
alpha=0.8,
|
347 |
+
zorder=3)
|
348 |
|
349 |
+
ax.fill_between(bimestres_deslocados, 0, notas_validas,
|
350 |
+
color=cores[idx % len(cores)], alpha=0.1)
|
351 |
|
352 |
for bim, nota in zip(bimestres_deslocados, notas_validas):
|
353 |
if nota is not None:
|
|
|
355 |
while any(abs(y - (nota + y_offset/20)) < 0.4 for y, _ in anotacoes_usadas.get(bim, [])):
|
356 |
y_offset += 5
|
357 |
|
358 |
+
ax.annotate(f"{nota:.1f}",
|
359 |
+
(bim, nota),
|
360 |
+
xytext=(0, y_offset),
|
361 |
+
textcoords="offset points",
|
362 |
+
ha='center',
|
363 |
+
va='bottom',
|
364 |
+
fontsize=9,
|
365 |
+
bbox=dict(facecolor='white',
|
366 |
+
edgecolor=cores[idx % len(cores)],
|
367 |
+
alpha=0.8,
|
368 |
+
pad=2,
|
369 |
+
boxstyle='round,pad=0.5'))
|
370 |
|
371 |
if bim not in anotacoes_usadas:
|
372 |
anotacoes_usadas[bim] = []
|
373 |
anotacoes_usadas[bim].append((nota + y_offset/20, nota))
|
374 |
|
375 |
titulo_grafico = titulo or 'Evolução das Médias por Disciplina'
|
376 |
+
ax.set_title(titulo_grafico, pad=20, fontsize=14, fontweight='bold')
|
377 |
+
ax.set_xlabel('Bimestres', fontsize=12, labelpad=10)
|
378 |
+
ax.set_ylabel('Notas', fontsize=12, labelpad=10)
|
379 |
|
380 |
ax.spines['top'].set_visible(False)
|
381 |
ax.spines['right'].set_visible(False)
|
382 |
|
383 |
+
ax.set_xticks([1, 2, 3, 4])
|
384 |
+
ax.set_xticklabels(['1º Bim', '2º Bim', '3º Bim', '4º Bim'], fontsize=10)
|
385 |
+
ax.set_ylim(0, ESCALA_MAXIMA_NOTAS)
|
386 |
|
387 |
+
ax.axhline(y=LIMITE_APROVACAO_NOTA, color=COR_REPROVADO, linestyle='--', alpha=0.3, linewidth=2)
|
388 |
+
ax.text(0.02, LIMITE_APROVACAO_NOTA + 0.1, 'Média mínima para aprovação',
|
389 |
+
transform=ax.get_yaxis_transform(), color=COR_REPROVADO, alpha=0.7)
|
390 |
|
391 |
if n_disciplinas > 8:
|
392 |
+
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=9, framealpha=0.8, fancybox=True, shadow=True,
|
393 |
+
ncol=max(1, n_disciplinas // 12))
|
394 |
else:
|
395 |
+
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', fontsize=10, framealpha=0.8, fancybox=True, shadow=True)
|
396 |
|
397 |
plt.tight_layout()
|
398 |
|
|
|
402 |
# Salvar com alta qualidade
|
403 |
nome_arquivo = nome_arquivo or 'evolucao_notas.png'
|
404 |
plot_path = os.path.join(temp_dir, nome_arquivo)
|
405 |
+
fig.savefig(plot_path, bbox_inches='tight', dpi=300, facecolor='white', edgecolor='none')
|
406 |
+
plt.close(fig)
|
407 |
|
408 |
return plot_path
|
409 |
+
|
410 |
def plotar_graficos_destacados(disciplinas_dados: List[Dict], temp_dir: str) -> str:
|
411 |
"""Plota gráficos de médias e frequências com visual aprimorado."""
|
412 |
n_disciplinas = len(disciplinas_dados)
|