aboutsummaryrefslogtreecommitdiff
path: root/src/admin/barplot.py
diff options
context:
space:
mode:
authorDaniel Saad Nogueira Nunes <danielsaad@users.noreply.github.com>2023-03-27 18:45:36 +0000
committerGitHub <noreply@github.com>2023-03-27 18:45:36 +0000
commitc1ad143de1e86e0a1bd4c42883befcbc037387f8 (patch)
treeacd82d2c6b76cf32f6f7fcc49090fbcb72f13475 /src/admin/barplot.py
parent7166a8d3f0d26a7ba80c057d95e0b45f83b57a71 (diff)
downloadboca-c1ad143de1e86e0a1bd4c42883befcbc037387f8.tar.gz
boca-c1ad143de1e86e0a1bd4c42883befcbc037387f8.zip
Create barplot.py (#24)
Creating barplot.py
Diffstat (limited to 'src/admin/barplot.py')
-rw-r--r--src/admin/barplot.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/admin/barplot.py b/src/admin/barplot.py
new file mode 100644
index 0000000..d07f156
--- /dev/null
+++ b/src/admin/barplot.py
@@ -0,0 +1,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)