Skip to content

Instantly share code, notes, and snippets.

@cerisara
Created January 21, 2020 08:28
Show Gist options
  • Save cerisara/9be8e18e6a11af62b69da99852de0473 to your computer and use it in GitHub Desktop.
Save cerisara/9be8e18e6a11af62b69da99852de0473 to your computer and use it in GitHub Desktop.
Easy-to-use script to plot histograms from a text file with gnuplot
#!/bin/bash
d=0.5
if [ $# -ge 2 ]; then
echo "2parms $1 $2"
d=$2
fi
rm -f /tmp/pp.gp
touch /tmp/pp.gp
echo 'set terminal x11 persist'>>/tmp/pp.gp
echo 'binwidth='$d>>/tmp/pp.gp
echo 'set boxwidth binwidth'>>/tmp/pp.gp
echo 'bin(x,width)=width*floor(x/width)+ binwidth/2.0'>>/tmp/pp.gp
echo 'plot "'$1'" using (bin($1,binwidth)):(1.0) smooth freq with boxes fs solid 0.25 notitle'>>/tmp/pp.gp
gnuplot /tmp/pp.gp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment