diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-02-23 14:45:03 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-02-23 14:45:03 +0100 |
commit | eddca01a8fcbcfb0e3bd1e2498f06cabf9ec80c8 (patch) | |
tree | 7ff398f55b5e91a4b411e0d6c9343b9e10eb217f /plot.sh |
Initial commit.
Diffstat (limited to 'plot.sh')
-rwxr-xr-x | plot.sh | 66 |
1 files changed, 66 insertions, 0 deletions
@@ -0,0 +1,66 @@ +#!/bin/bash + +SELECT="$1" +OUTPUT="$2" + +DATA=`mktemp` +cat > "$DATA" + +function gnuplot_conf { + # data format + echo "set timefmt '%Y-%m-%d'" + + # X axis + echo "set xlabel ''" + echo "set format x '%b %d'" + echo "set xdata time" + echo "set xtics 604800 rotate by 45 right font ', 7'" + echo "unset mxtics" + + # grid + echo "set grid" + + # legend + echo "set key outside bottom center" + + # file output (for scripts) + if [ ! -z "$OUTPUT" ]; then + echo "set terminal pngcairo size 960, 480 font 'Liberation Serif,12'" + echo "set output '$OUTPUT'" + fi + + # timestamp + TS="{/*0.7 `date`}" + + if [ "$SELECT" == "population" ]; then + echo "set title \"Population over time\n$TS\"" + echo "set ylabel 'Players'" + echo -n "plot '$DATA' " + echo -n "using 1:2 title 'Mean player count', " + echo "'' using 1:9 title 'Peak player count'" + elif [ "$SELECT" == "ping" ]; then + echo "set title \"Mean ping over time\n$TS\"" + echo "set ylabel 'Mean ping'" + echo -n "plot '$DATA' using 1:3 axes x1y1 title 'Mean ping'" + elif [ "$SELECT" == "ping-distrib" ]; then + echo "set title \"Ping distribution over time\n$TS\"" + echo "set ylabel 'Fraction of players'" + echo "set yrange [0:1]" + echo -n "plot '$DATA'" + echo -n "using 1:4 title 'Above 60', " + echo -n "'' using 1:5 title 'Above 110', " + echo -n "'' using 1:6 title 'Above 160', " + echo -n "'' using 1:7 title 'Above 210', " + echo "'' using 1:8 title 'Above 260'" + else + echo "SELECT is wrong" 1>&2 + fi +} + +if [ -z "$OUTPUT" ]; then + gnuplot -p -c <(gnuplot_conf) +else + gnuplot -c <(gnuplot_conf) +fi + +rm -f "$DATA" |