- Line graphs 📈📉
- Bar graphs 📊
Plot graphs using the terminal. E.g.,
> cat sensor.txt | awk -F ':| *' '{print $2}' | eplot -d -t CO2 2> /dev/null
4000 +-------------------------------------------------------------------+
| + +.+.+ + + + + |
| : .+ CO2 +.....+ |
| + .+ |
3500 |-+ : .+ +-|
| : .+ |
| + .+ |
| : + |
3000 |-+ : + +-|
| : .+ |
| : .+.+ |
| : .+ |
2500 |-+ : .+ +-|
| + .+.+ |
| + .+.+ |
| + +.+.+ |
2000 |-+ + .+.+.+.+ +-|
| + |
| + |
|.+.+.+ + + + + + + |
1500 +-------------------------------------------------------------------+
0 5 10 15 20 25 30 35
Install gnuplot
and eplot
. Follow their instructions, or...
# if ruby not installed
# sudo apt-get install ruby-full
sudo apt install gnuplot
sudo wget -q -O /usr/bin/ec https://raw.githubusercontent.com/chriswolfvision/eplot/master/ec
sudo wget -q -O /usr/bin/eplot https://raw.githubusercontent.com/chriswolfvision/eplot/master/eplot
eplot
uses files or data piped into it.
Create data file
echo 'Co2:1679 Temperature:18.01 Humidity:59.37
Co2:1677 Temperature:17.60 Humidity:60.69
Co2:1676 Temperature:17.34 Humidity:61.72
Co2:1679 Temperature:17.57 Humidity:62.62
Co2:1883 Temperature:18.94 Humidity:64.58
Co2:2173 Temperature:19.51 Humidity:68.00
Co2:2377 Temperature:21.16 Humidity:71.40
Co2:3207 Temperature:21.46 Humidity:74.27
Co2:3675 Temperature:20.71 Humidity:77.39
Co2:3886 Temperature:19.91 Humidity:80.15
Co2:3907 Temperature:19.23 Humidity:81.84
Co2:3898 Temperature:18.75 Humidity:81.75
Co2:3803 Temperature:18.32 Humidity:80.84
Co2:3667 Temperature:17.94 Humidity:79.86
Co2:3513 Temperature:17.62 Humidity:79.13
Co2:3347 Temperature:17.28 Humidity:78.46
Co2:3190 Temperature:17.00 Humidity:78.01
Co2:3038 Temperature:16.75 Humidity:77.68
Co2:2914 Temperature:16.50 Humidity:77.39
Co2:2796 Temperature:16.26 Humidity:77.13
Co2:2703 Temperature:16.05 Humidity:76.93
Co2:2599 Temperature:15.89 Humidity:76.79
Co2:2509 Temperature:15.72 Humidity:76.65
Co2:2433 Temperature:15.58 Humidity:76.50
Co2:2362 Temperature:15.49 Humidity:76.39
Co2:2291 Temperature:15.39 Humidity:76.18
Co2:2233 Temperature:15.33 Humidity:76.10
Co2:2177 Temperature:15.23 Humidity:75.98
Co2:2127 Temperature:15.22 Humidity:75.83
Co2:2091 Temperature:15.18 Humidity:75.78
Co2:2057 Temperature:15.07 Humidity:75.87
Co2:2022 Temperature:15.00 Humidity:75.90
Co2:1989 Temperature:14.95 Humidity:75.83
Co2:1962 Temperature:14.90 Humidity:75.77' > sensor.txt
> cat sensor.txt | awk -F ':| *' '{print $2}' | eplot -d -t CO2 2> /dev/null
4000 +-------------------------------------------------------------------+
| + +.+.+ + + + + |
| : .+ CO2 +.....+ |
| + .+ |
3500 |-+ : .+ +-|
| : .+ |
| + .+ |
| : + |
3000 |-+ : + +-|
| : .+ |
| : .+.+ |
| : .+ |
2500 |-+ : .+ +-|
| + .+.+ |
| + .+.+ |
| + +.+.+ |
2000 |-+ + .+.+.+.+ +-|
| + |
| + |
|.+.+.+ + + + + + + |
1500 +-------------------------------------------------------------------+
0 5 10 15 20 25 30 35
For this, we need to just use gnuplot
. Create a data file like this (first column is used for x value [position along axis], second for x label, and third for y value)
0 "eating" 2
1 "sleeping" 5
2 "basking" 3
Then, you can either create a commands.txt
file like this and run gnuplot commands.txt
# display to terminal
set term dumb
# or save to png
set term png
set output "graph.png"
set title "my enjoyment of several activities"
set ylabel "enjoyment / a.u."
set xtics rotate by 45 right
set boxwidth 0.5
set style fill solid
set yrange[0:]
set offsets 0,0,1,0
# 1:3:xtic(2) uses 1st col as xvals, 3rd col as yvals, and 2nd col as xtick labels
# notitle disables legend
plot "data.dat" using 1:3:xtic(2) with boxes notitle
or run the commands all-at-once with gnuplot -e
# plot from commands file, or...
gnuplot commands.txt
# ...convert file to string
cat commands.txt | sed 's/^#.*//g' | sed -z 's/\n\n/\n/g' | tr '\n' '; '
# plot !
$ gnuplot -e 'set term dumb; set title "my enjoyment of several activities";set ylabel "enjoyment / a.u.";set xtics rotate by 45 right;set boxwidth 0.5;set style fill solid;set yrange[0:];set offsets 0,0,1,0;;plot "data.dat" using 1:3:xtic(2) with boxes notitle'
my enjoyment of several activities
6 +-------------------------------------------------------------------+
| + + + |
| |
5 |-+ ************* +-|
| * * |
| * * |
4 |-+ * * +-|
| * * |
| * * |
3 |-+ * * ************ +-|
| * * * * |
| * * * * |
2 |-+ ************ * * * * +-|
| * * * * * * |
| * * * * * * |
1 |-+ * * * * * * +-|
| * * * * * * |
| * + * * + * * + * |
0 +-------------------------------------------------------------------+
eating sleeping basking