aboutsummaryrefslogtreecommitdiff
path: root/src/admin/report/barplot.py
blob: edc9df14dfc13cd897e353d5fbcaf2ab6dce0a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import matplotlib.pyplot as plt
import sys

filename = sys.argv[1]
title = sys.argv[2]


x = [str(x) + "-" + str(x + 10) for x in range(0, 300, 10)]

with open(filename, "r") as file:
    y = [int(line) for line in file]

# Create a bar plot
plt.bar(x, y, width=0.5)


# Set the y-axis tick labels to step by 5
plt.xticks(rotation=90)
if max(y) < 200:
    plt.yticks(range(0, max(y) + 1, 5))
else:
    plt.yticks(range(0, max(y) + 1, 10))
# Add gridlines to the y-axis
plt.grid(axis="y")

# Add a title to the plot
plt.title(title)

plt.tight_layout()

# Show the plot
plt.savefig(filename.replace(".txt", ".png"), dpi=600, transparent=True)