Skip to content

Instantly share code, notes, and snippets.

@cyrus-and
Last active August 29, 2015 14:00
Show Gist options
  • Save cyrus-and/11309401 to your computer and use it in GitHub Desktop.
Save cyrus-and/11309401 to your computer and use it in GitHub Desktop.
Gnuplot wrapper with better defaults for quick line charts
#!/usr/bin/env bash
#
# QuickPlot - Gnuplot wrapper with better defaults for quick line charts
#
# Usage:
# qp < file.dat
# qp file-1.dat file-2.dat ...
#
# File formats:
# - <x>
# - <x> <y>
COMMANDS='
line_width = 1.25;
set style line 1 linetype 1 linecolor rgb "#0099cc" linewidth line_width;
set style line 2 linetype 1 linecolor rgb "#9933cc" linewidth line_width;
set style line 3 linetype 1 linecolor rgb "#669900" linewidth line_width;
set style line 4 linetype 1 linecolor rgb "#ff8800" linewidth line_width;
set style line 5 linetype 1 linecolor rgb "#cc0000" linewidth line_width;
set style line 6 linetype 2 linecolor rgb "#0099cc" linewidth line_width;
set style line 7 linetype 2 linecolor rgb "#9933cc" linewidth line_width;
set style line 8 linetype 2 linecolor rgb "#669900" linewidth line_width;
set style line 9 linetype 2 linecolor rgb "#ff8800" linewidth line_width;
set style line 10 linetype 2 linecolor rgb "#cc0000" linewidth line_width;
set style line 11 linetype 3 linecolor rgb "#0099cc" linewidth line_width;
set style line 12 linetype 3 linecolor rgb "#9933cc" linewidth line_width;
set style line 13 linetype 3 linecolor rgb "#669900" linewidth line_width;
set style line 14 linetype 3 linecolor rgb "#ff8800" linewidth line_width;
set style line 15 linetype 3 linecolor rgb "#cc0000" linewidth line_width;
set style line 16 linetype 4 linecolor rgb "#0099cc" linewidth line_width;
set style line 17 linetype 4 linecolor rgb "#9933cc" linewidth line_width;
set style line 18 linetype 4 linecolor rgb "#669900" linewidth line_width;
set style line 19 linetype 4 linecolor rgb "#ff8800" linewidth line_width;
set style line 20 linetype 4 linecolor rgb "#cc0000" linewidth line_width;
set style line 21 linetype 5 linecolor rgb "#0099cc" linewidth line_width;
set style line 22 linetype 5 linecolor rgb "#9933cc" linewidth line_width;
set style line 23 linetype 5 linecolor rgb "#669900" linewidth line_width;
set style line 24 linetype 5 linecolor rgb "#ff8800" linewidth line_width;
set style line 25 linetype 5 linecolor rgb "#cc0000" linewidth line_width;
set style increment user;
set termoption dash;
set grid;
plot'
if [ -t 0 ]; then
# not piped input
for FILE in "$@"; do
COMMANDS="${COMMANDS} \"$FILE\" with lines,"
done
else
# piped input
COMMANDS="${COMMANDS} \"-\" with lines title \"$1\""
fi
gnuplot -p -e "$COMMANDS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment