#!/bin/bash _helpexit() { self=$( basename $0 ) echo "Plot2D for console. Arguments $self FILE xCol yCol [-X] [plotStyle] [preBlock] e.g. $self cal.tsv 2 4 or $self cal.tsv Area Weight \"with lines;\" \"set title 'test plot';\" preBlock may contain any GNUPlot commands. plotStyle contains any plotting style commands. -X use X11 instead of console Requires csvkit and gnuplot " exit } if [ $# -lt 3 ]; then _helpexit; fi POS=0 POSADJUST=0 for (( i=1; i<=$#; i++ )); do POS=$(( $i + $POSADJUST )) [[ ${!i} = "-h" ]] && _helpexit [[ ${!i} = "help" ]] && _helpexit [[ ${!i} = "-X" ]] && PLOTTERM=" " && POSADJUST=$(( $POSADJUST - 1 )) && continue [[ $POS -eq 1 ]] && FILE="${!i}" [[ $POS -eq 2 ]] && XCOL="${!i}" [[ $POS -eq 3 ]] && YCOL="${!i}" [[ $POS -eq 4 ]] && STYLE="${!i}" [[ $POS -eq 5 ]] && PRE="${!i}" done fbase=$( basename "$FILE" ) [[ -z "$PLOTTERM" ]] && PLOTTERM="set term dumb $(tput cols) $(tput lines) enhanced;" [[ -z "$PRE" ]] && PRE="set title '$fbase';" csvcut -t -c "$XCOL,$YCOL" "$FILE" | gnuplot -p -e "$PLOTTERM set datafile separator \",\"; set xlabel '$XCOL'; set ylabel '$YCOL'; $PRE plot '