Skip to main content

Posts

Showing posts from September, 2011

Gnuplot to plot histogram

GNUPLOT can be used to generate histograms. The script below allows one to plot variations in angle from 0° to 180°. Each histogram box width correspond to 3° (covered here under bw option). To execute this script; type this in the terminal: gnuplot histogram.p You should be in the folder where below script is saved in a file name "histogram.p" and a dat file (here, it is N---H-O.dat) should be present. histogram.p ------------------ set term gif set output "angle_N---H-O.gif" set xrange [0.0:180.0] set boxwidth 2.0 absolute set style fill solid 1.0 border -1 set xtics 10 set title "molecule 3.0A Angle N---H-O" set ylabel "occurance" set xlabel "angle" bw = 3   # substitute what you want bin(x,width)=width*floor(x/width) plot 'N---H-O.dat' using (bin($2,bw)):(1.0) smooth freq with boxes ------------------ The dat file is an input file with data in the format: 0    23.680344 1    73.766251 2    67.4