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...

2 Responses to “Quick and Easy Histograms in gnuplot”

  1. Philipp K Janert Says:

    I saw your posting regarding Gnuplot, and thought you might be interested to know that there is now a book on it: “Gnuplot in Action”. You can pre-order it directly from the publisher: Manning: Gnuplot in Action.

    If you want to learn more about the book and the author, check out my book page at Principal Value - Gnuplot in Action.

    Let me know if you are interested in a review copy.

  2. Alfredo Says:

    I have just one column and with it I want to make a histogram (x-axis for the numbers in my column, y-axis for the amount of values in the bin). Do you know how to do that?

    cheers,
    Alfredo

Leave a Reply