Quick and Easy Histograms in gnuplot

I have to create histograms quite frequently for my Digital Signal Processing class this semester. Here’s a quick gnuplot setup for a histogram. You can either type these commands into gnuplot, or enter them into a file (usually with a .gpi extension), and use ‘gnuplot file.gpi’ or ‘load file.gpi’ inside gnuplot.

example:

set boxwidth VALUE # Probably 3-5.
set xlabel "STRING"
set ylabel "STRING"
set term svg # Create an SVG image
set output 'file.svg'
set key off # Unless you really want a key
# For this next line, lw is linewidth (2-4)?
plot [XMIN:XMAX] ‘myHistogramData’ with boxes lw VALUE

The input is expected to be in this format:

x-value y-value
x-value y-value
etc...

Leave a Reply