csv2plot.sh (716B)
1 #!/bin/sh 2 OUTPUT=$1 3 X_AXIS=$2 4 Y_AXIS=$3 5 shift 3 6 7 HEADER=$(dirname $0)/header.sh 8 9 if [ $# -lt 1 ]; then 10 exit 11 fi 12 13 X_LABEL=$($HEADER $X_AXIS $1) 14 Y_LABEL=$($HEADER $Y_AXIS $1) 15 16 X_MIN=$(cat $1 | awk 'NR != 1 {print $'$X_AXIS'}' | sort -h | head -n1) 17 X_MAX=$(cat $1 | awk 'NR != 1 {print $'$X_AXIS'}' | sort -h | tail -n1) 18 19 PLOT="" 20 while [ $# -gt 0 ]; do 21 if [ "$PLOT" != "" ]; then 22 PLOT="$PLOT, " 23 fi 24 PLOT="$PLOT'$1' using $X_AXIS:$Y_AXIS title '$2' with boxes lw 1.25" 25 shift 2 26 done 27 28 gnuplot -e "set terminal pdf; set output '$OUTPUT'; set datafile separator ' '; set xlabel '$X_LABEL' font ',12'; set ylabel '$Y_LABEL' font ',12'; set boxwidth 0.8; set xrange [$(($X_MIN - 1)):$(($X_MAX + 1))]; plot $PLOT" 29