2026-rff_mp/GutovVM/docs/data/lab_2_data/graphics.py

29 lines
941 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#Графики
import matplotlib.pyplot as plt
import pandas as pd
df = pd.read_csv('results.csv', header=None, names=['lab','strategy','timeMs','cellsVisited','pathLength'])
print(df)
df_time = df.pivot(index='lab', columns='strategy', values=['timeMs','cellsVisited','pathLength'])
print(df_time)
# 1. График только для Времени
df_time["timeMs"].plot(kind="bar", figsize=(10, 5), rot=0)
plt.title("Время работы стратегий (мс)")
plt.ylabel("timeMs")
plt.show()
# 2. График для Посещенных клеток
df_time["cellsVisited"].plot(kind="bar", figsize=(10, 5), rot=0)
plt.title("Количество посещенных клеток")
plt.ylabel("cellsVisited")
plt.show()
# 3. График для Длины пути
df_time["pathLength"].plot(kind="bar", figsize=(10, 5), rot=0)
plt.title("Длина найденного пути")
plt.ylabel("pathLength")
plt.show()