Plotting Data with Gnuplot

Gnuplot is an interactive plotting utility. You need to run Gnuplot under the X Window System because it uses an X window as the output device. Gnuplot is a command-line-driven program; it prompts you and accepts your input commands. In response to those commands, Gnuplot displays various types of plots. The output appears in an X window.

To install Gnuplot, log in as root, mount the DVD-ROM, and type the following commands in a terminal window (change /media/cdrom to /media/cdrecorder if you are using a CD/DVD recorder):

cd /media/cdrom/Fedora/RPMS rpm -ivh gnuplot*.rpm

$-Fi]i) 1Edit {»Vi«* |#Halp |.t«iBfcgry.f ig Current iipirs "tunatnry.fig" Í21? ntijßcfcs)

Lcfy m i p

& telele

2 firnU Blank

Figure 10-11: A Sample Drawing Displayed in xfig.

After installing Gnuplot, type gnuplot in a terminal window. Gnuplot displays an opening message and waits for further input at the prompt, as shown in Figure 10-12.

File Edit View Terminal Tabs Help GNUPLOT Version 4,0 patchlevel 0 last modified Thu Apr 15 14:44:22 CEST 2004 System: Linux 2.6,11-1<1233_FC4

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

This is gnuplot version 4.0. Please refer to the documentation for command syntax changes. The old syntax will be accepted throughout the 4.0 seriest but all save files use the new syntax.

Type help" to access the on-line reference manual. The gnuplot FAQ is available from

Send comments and requests for help to

<gnuplot-info©> Send bugs, suggestions and mods to


Terminal type set to 'xll1 gnuplot>

Figure 10-12: Running Gnuplot in a Terminal Window.

How Reference Chart Paper

At any time in Gnuplot, you can ask for online help. The help is similar to that in the old DEC VAX/VMS system. To learn more about the plot command, for example, type help plot at the Gnuplot prompt.

Gnuplot also comes with several example files that appear in the / usr/lib/gnuplot/demos directory of your system. To try these demo files, type the following commands in a terminal window:

cd /usr/share/doc/gnuplot*

cd demo gnuplot

When the Gnuplot prompt appears, load one of the demo files (the ones with the .dem extension) with the load command. To load the world.dem file, for example, type the following command at the Gnuplot prompt:

load "world.dem"

The world.dem Gnuplot file displays a map of the world and pauses until you press Enter (before you do so, click the terminal window where you started Gnuplot). After you press Enter, Gnuplot displays the next plot, which happens to be a view of the earth in spherical coordinates, as shown in Figure 10-14.

Drawing Gnuplot
Figure 10-14: A 3D Plot of the World in Gnuplot.

If you are curious about the world.dem file, here's what it contains:

# $Id: world.dem,v 1.8 2003/10/28 05:35:54 sfeam Exp $

set title "Gnuplot Correspondences"

unset key unset border unset yzeroaxis unset xtics unset ytics #

# plot world map and correspondent locations as a +

plot 'world.dat' with lines 3 4, 'world.cor' with points 1 2

set title ""

set key on set border set yzeroaxis set xtics set ytics pause -1 "Hit return to continue"

# plot a '3D version using spherical coordinate system' of the world. set angles degrees set title "3D version using spherical coordinate system"

set ticslevel 0

set mapping spherical set parametric set samples 32

set isosamples 9

set vrange [0:360]

splot cos(u)*cos(v),cos(u)*sin(v),sin(u) with lines 5 6,\ 'world.dat' with lines 3 4, 'world.cor' with points 1 2 pause -1 "Hit return to continue"

# HBB 20000715: new demo:

# same plot, but with hidden3d active, plus axes through the

set title "3D solid version through hiddenlining" set hidden3d set arrow from 0,0,-1.2 to 0,0,1.2 lt 5 lw 2

set arrow from -1.2, 0, 0 to 1.2, 0, 0 nohead lt 5 lw 1

set arrow from 0, -1.2, 0 to 0, 1.2, 0 nohead lt 5 lw 1

splot cos(u)*cos(v),-cos(u)*sin(v),sin(u) with lines 5 6,\

'world.dat' u 1:2:(1.001) with lines 3 4, 'world.cor' with points 1 2

pause -1 "Hit return to continue"

unset arrow unset hidden

# plot a '3D version using cylindrical coordinate system' of the world.

set title "3D version using cylindrical coordinate system"

set ticslevel 0.0

set mapping cylindrical set parametric set samples 32

set isosamples 9

set urange [-180:180]

'world.dat' with lines 3 4, 'world.cor' with points 1 2

pause -1 "Hit return to continue"


As the listing shows, the world.dem file consists of Gnuplot commands. You can learn a great deal about Gnuplot by trying each file in the Gnuplot demo directory and by studying the commands in the file.

Was this article helpful?

+1 0
Article Marketing Gold

Article Marketing Gold

Discover How You Can Use The Huge Power of Article Marketing To Drive Highly Targeted Traffic To Your Website and Instantly Become THE Person Your Prospects Want To Buy From.

Get My Free Ebook


  • Kia
    How to run gnuplot from the command line in fedora?
    7 years ago
    How to install gnuplot in fedora 14?
    7 years ago
  • dieter
    How can i download gnuplot on fedora 14?
    7 years ago
  • aleisha walker
    How to install gnuplot on fedora core 12?
    7 years ago
  • harold boeding
    How to draw graph of my datas by gnuplot on linux system?
    2 years ago

Post a comment