-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot
executable file
·115 lines (87 loc) · 2.68 KB
/
plot
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# HEADER =========================================================================
# Author: Loïc Delineau
# Date: 16/10/2024
# Platform : WSL2 & Linux (Ubuntu 24.04)
# Description: Plots data
# GLOBAL VARIABLES ===============================================================
# tput setaf colours
#
# Color #define Value RGB
# black COLOR_BLACK 0 0, 0, 0
# red COLOR_RED 1 max,0,0
# green COLOR_GREEN 2 0,max,0
# yellow COLOR_YELLOW 3 max,max,0
# blue COLOR_BLUE 4 0,0,max
# magenta COLOR_MAGENTA 5 max,0,max
# cyan COLOR_CYAN 6 0,max,max
# white COLOR_WHITE 7 max,max,max
black=0
red=1
green=2
yellow=3
blue=4
magenta=5
cyan=6
white=7
# FUNCTIONS ======================================================================
# Wait for user confirmation (y) to continue or (n) to quit
prompt() {
echo "Continue by entering 'y', stop the script by pressing 'n'"
# Failsafe for wrong value inputted
fail="1"
while [[ "$fail" == "1" ]]; do
# Read 1 input char
echo -n "> "
read -n 1 -r cmd < /dev/tty
# Keyboard input checking
if [[ "$cmd" == "y" ]]; then
fail="0"
echo ""
elif [[ "$cmd" == "n" ]]; then
echo ""
exit
else
echo -e "\nUnknown key..."
fi
done
}
# USER SYSTEM IDENTIFICATION =====================================================
# Checking if you are running this in Linux or WSL2
if `uname -r | grep -q WSL2`; then
echo "You are running WSL2"
OS=WSL2
elif `uname -r | grep -q generic`; then
echo "You are running Bare Metal Linux"
echo "This script doesn't yet work for Linux, exiting..."
OS=LINUX
else
echo "You are not running Linux, this script won't work"
echo "Killing script, please get off your proprietary OS"
exit
fi
echo ""
# GENERATING GRAPH ==============================================================
# Finding class ID
ID=""
echo "Please enter the number of the class you wish to preview:"
# Putting all elements of dataset in a numbered list in a new file
ls ./dataset >> temp # doing this to display as a list
cat -n temp
echo ""
echo -n "> " && read ID
echo ""
FILE="$(sed -n "${ID}p" temp)" # print ID line of file
echo "File you requested is: $FILE"
rm temp
echo "Generating graphs..."
# Generating Graphs
gnuplot -e 'set terminal png; plot "'./dataset/$FILE'" with lines' > graph.png
# Viewing Graphs
xdg-open graph.png
# wslview graph.png --> for wsl2
echo "Success! Now Exiting"
echo ""
exit
gnuplot -e 'set terminal png; plot "data1" using 1:2 with lines title "Class Hours" lt
7 lc 6, "data1" using 1:3 with lines title "Work Hours" lc 7' > graph.png; xdg-open graph.png