Plotting Data with GnuPlot

If you have a very, very large file with a lot of data points in it, it might be painfully slow to try to open the file in Excel in order to make a plot of a subset of the data. We have a 2.3GB file of XY points where we want to plot only a couple columns. In this case, gnuplot works really well.

Here's a small sample of what our data looks like:

Vcomp\<0\> X,Vcomp\<0\> Y,Vcomp\<1\> X,Vcomp\<1\> Y

In the actual data file, there are 4096 X and Y columns and over 100,000 lines in each column.

Our first step is to make a plot file to use in gnuplot. Ours is called and looks like this:

# Set size of output image
set terminal png size 1200,800

# Set name of output file.  The quotes are required
set output "out.png"

# Set style of plot.  We want lines
set style data lines

# Set how the data is separated in the file
set datafile separator ","

# Set the title of the plot
set title "Analog Block 3 Reduced Sim 2"

# The actual data to plot
# using 1:2 means column 1 is on the X axis and column 2 is on the Y
# with lines means to connect the points with lines
# t "Col 0 XY" is the title for the legend

# If you want to plot multiple xy pairs on the same graph, do this

plot "Analog_block_3_reduced_sim2.csv" using 1:2 with lines t "Col 0 XY", \
 "" using 3:4 t "Col 1 XY", \
 "" using 5:6 t "Col 2 XY"

Then we just start gnuplot and load our plot file.

yo:simulation $ gnuplot

	G N U P L O T
	Version 4.6 patchlevel 1    last modified 2012-09-26 
	Build System: Darwin x86_64

	Copyright (C) 1986-1993, 1998, 2004, 2007-2012
	Thomas Williams, Colin Kelley and many others

	gnuplot home:
	faq, bugs, etc:   type "help FAQ"
	immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'aqua'
gnuplot> load ""

When it finishes, which can take a few minutes, there will be a file in your directory called out.png which is our plot. A sample of one of our plots is below.

our output file
Updated: December 2013