2026-rff_mp/VildyaevAV/docs/task2/plot_results.py

50 lines
937 B
Python
Raw Normal View History

2026-05-21 18:50:03 +00:00
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("maze_results.csv")
mazes = df["maze"].unique()
for maze in mazes:
maze_df = df[df["maze"] == maze]
plt.figure(figsize=(8, 5))
plt.bar(
maze_df["strategy"],
maze_df["time_ms"]
)
plt.title(f"Time for {maze}")
plt.ylabel("Time ms")
plt.xlabel("Strategy")
plt.tight_layout()
filename = maze.split("/")[-1].replace(".txt", "_time.png")
plt.savefig(filename)
plt.close()
for maze in mazes:
maze_df = df[df["maze"] == maze]
plt.figure(figsize=(8, 5))
plt.bar(
maze_df["strategy"],
maze_df["visited_cells"]
)
plt.title(f"Visited cells for {maze}")
plt.ylabel("Visited cells")
plt.xlabel("Strategy")
plt.tight_layout()
filename = maze.split("/")[-1].replace(".txt", "_visited.png")
plt.savefig(filename)
plt.close()
print("Graphs created")