Table of Contents > Linux > GNUPlot Reference

GNUPlot Reference

GNUPlot is piece of graphing software for Unix and Windows computers. It allows you to easily plot mathematical funtions and/or data points in 2D or 3D, all from the command-line. Because it is so flexible and powerful, it is also somewhat complicated and hard to understand at first. This page is a quick reference to a few of the operations of GNUPlot.

Graphing

plot sin(x)
Plots the function sin(x).
plot sin(x), cos(x)
Plots both sin(x) and cos(x), each in its own color.
replot
Re-executes the last plot command.
plot "datafile"
Opens the file "datafile" and plots the first white-space delimited column.
plot "datafile" using 1:3
Plots the first and third column of data in "datafile".
plot "datafile" using 1:3, "datafile" using 2:4
Plots columns 1:3 and 2:4 on the same graph.
plot "datafile" using 1:3 t "Revenue", "datafile" using 2:4 t "Expenses"
Same as above but changing the key titles for each line.

Axis Control

set xrange [-10:10]
Sets the range on the x-axis from -10 to 10. Identical to the "set yrange" command.
set xtics .5
Sets the numeric frequency of tics on the x-axis to .5. Identical to the "set ytics" command.
set xlabel "Distance"
Sets the label on the x-axis to "Distance". Identical to the "set ylabel" command.

Misc. Options

set title "Hello World!"
Sets the title for the entire graph to "Hello World!"
set nokey
Turns off the key/legend.
set key [left|right|top|bottom|outside|below]
Places the key in either the left or right corner. Multiple words may be used.
set terminal png small color
Outputs the graph to a .png file instead of the screen.
set output "graphic.png"
Sets the output filename to "graphic.png".
set grid
Turns on a grid.
set noborder
Turns off the border.
Page View Tracker