Skip to content

Instantly share code, notes, and snippets.

@brunoro
Created June 25, 2013 20:06
Show Gist options
  • Save brunoro/5861895 to your computer and use it in GitHub Desktop.
Save brunoro/5861895 to your computer and use it in GitHub Desktop.
Handy plotting script using gnuplot. Plots all the data on .dat files on the current directory, using the first and second columns as data.
#!/bin/bash
GPI="plot.gpi"
echo "set terminal svg size 480,320 fname 'Gill Sans' fsize 8 rounded dashed
# set background
set object 1 rect from screen 0, 0, 0 to screen 1, 1, 0 behind
set object 1 rect fc rgb 'white' fillstyle solid 1.0
# Line style for axes
set style line 80 lt 0
set style line 80 lt rgb '#808080'
# Line style for grid
set style line 81 lt 3 # dashed
set style line 81 lt rgb '#808080' lw 0.5 # grey
# Remove border on top and right.
# These borders are useless and make it harder
# to see plotted lines near the border.
# Also, put it in grey; no need for so much emphasis on a border.
set grid back linestyle 81
set border 3 back linestyle 80
set xtics nomirror
set ytics nomirror
# Line styles: try to pick pleasing colors, rather
# than strictly primary colors or hard-to-see colors
# like gnuplot's default yellow. Make the lines thick
# so they're easy to see in small plots in papers.
set style line 1 lt 1
set style line 2 lt 1
set style line 3 lt 1
set style line 4 lt 1
set style line 1 lt rgb '#A00000' lw 2 pt 7
set style line 2 lt rgb '#00A000' lw 2 pt 9
set style line 3 lt rgb '#5060D0' lw 2 pt 5
set style line 4 lt rgb '#F25900' lw 2 pt 13
#set style data linespoints
set key top left
set ylabel 'ms'
set xlabel 'data structure depth'
set output 'data.svg'
"> $GPI
echo -en "plot \\" >> $GPI
NUM=1
for FILE in *.dat; do
echo -en "\n '$FILE' using 1:2 title '`basename $FILE .dat`' w lp ls $NUM,\\" >> $GPI
((NUM++))
done
sed -i '$s/,\\$//' $GPI
echo >> $GPI
cat $GPI
gnuplot $GPI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment