/
NSir
/
student-progress-visualizer
Обзор
Документация
Войти
/
NSir
/
student-progress-visualizer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/visualizer.py
59 строк
1 KB
NSir
Initial commit
23 май 2026, 19:41
23 май 2026, 19:41
9a83b4d
Код
Авторство
О чём код?
from pathlib import Path import matplotlib.pyplot as plt import seaborn as sns import pandas as pd def setup_plot_style() -> None: """ Настройки внешнего вида графиков. """ sns.set_theme(style="whitegrid") plt.rcParams["axes.unicode_minus"] = False def plot_progress( df: pd.DataFrame, title: str, output_path: str | Path | None = None, show: bool = True, ) -> None: """ Строит график динамики баллов. """ setup_plot_style() if df.empty: raise ValueError("Нет данных для построения графика") fig, ax = plt.subplots(figsize=(12, 7)) metrics = ["Лекции", "Тесты", "Задания", "Итог"] for metric in metrics: sns.lineplot( data=df, x="Дата", y=metric, marker="o", label=metric, ax=ax, ) ax.set_title(title, fontsize=16) ax.set_xlabel("Дата выгрузки") ax.set_ylabel("Баллы") ax.legend(title="Показатель") ax.grid(True) plt.xticks(rotation=30) plt.tight_layout() if output_path is not None: output_path = Path(output_path) output_path.parent.mkdir(parents=True, exist_ok=True) plt.savefig(output_path, dpi=150, bbox_inches="tight") if show: plt.show() else: plt.close(fig)