From 2b0829c78e97ff1529e734db5e10d60925262039 Mon Sep 17 00:00:00 2001 From: Daniel Svitan Date: Sat, 21 Dec 2024 16:45:58 +0100 Subject: [PATCH] :sparkles: Adds plotting histogram --- distribution.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/distribution.py b/distribution.py index 512d0f6..c8f427c 100644 --- a/distribution.py +++ b/distribution.py @@ -35,6 +35,17 @@ def plot_pie(data, labels, title, explode=None): plt.show() +def plot_hist(data, title, xlabel, ylabel): + plt.figure(figsize=(8, 6)) + plt.hist(data, 25, edgecolor="black") + plt.title(title) + plt.xlabel(xlabel) + plt.ylabel(ylabel) + + plt.tight_layout() + plt.show() + + grade = dataset[:, 0] grade_dist = [ len(grade[grade == 1]) / len(grade), @@ -74,7 +85,9 @@ if graph: print("--- GPA ---") print("n/a") print("") -# TODO: graph numerical + +if graph: + plot_hist(dataset[:, 2], "Distribúcia piemernu známok", "Piemerná známka", "Počet študentov/tiek") math = dataset[:, 3] math_dist = [ @@ -231,4 +244,6 @@ if graph: print("--- ABSENCE ---") print("n/a") print("") -# TODO: graph numerical + +if graph: + plot_hist(dataset[:, 11], "Distribúcia absencií", "Počet neprítomných hodín", "Počet študentov/tiek")