Experiment 2 Introduction to Plotting Software
EXPERIMENT 2
INTRODUCTION TO
PLOTTING SOFTWARE
Structure
2.1 Introduction
2.2 Plotting Inbuilt Functions
2.3 Plotting from Data Files
2.1 INTRODUCTION
In this experiment we introduce you to the commonly used plotting software GNUPLOT. It is a
copyrighted but freely distributed software that can generate two and three dimensional plots
of functions and data. It is widely used in the scientific community and has been under active
development since 1986. The latest release to date is gnuplot 6.0 Dec 2023 ( 6 6.0.2
6.0
.0.2
.0.2 Dec 2024).
We focus on some of the basic commands that will help you get started with plotting using
GNUPLOT. You may like to look at the ht http://www.gnuplot.info/
http://www
ww.gnu
ww nupl
plot
plot.i
.inf
.info/
o/ for details about GNUPLOT.
The complete documentation for GNUPLOT 6.1 is available at
http://gnu
http://gnuplot.info/docs_6.1/loc8468.html.You
nupl
plot
ot.info/docs_6.1/loc
oc84
8468.html.You can learn how to use gnuplot to create all kinds of
plots by following the link http://gnuplot.sourceforge.net/demo . When you open gnuplot on your
computer (in WINDOWS), I t shows up as a box as shown in Fig 2.1 below.
Fig. 2.1 : Opening Terminal for GNUPLOT
31
Block 3 Laboratory Manual
Notice that there is command prompt gnuplot> on the terminal. You will type in
your plotting commands in front of this command prompt.
2.2 PLOTTING INBUILT FUNCTIONS
GNUPLOT has several inbuilt functions. You can access a complete list of
functions at the link http://gnuplot.info/docs_6.1/loc1303.html. Let us first learn
how to plot inbuilt functions.
Suppose we wish to plot the inbuilt function sin(x) in the interval - 2p £ x £ 2p .
Let us do it in steps. We list the plotting command to be typed in front of the
command prompt gnuplot> in column 1 and the corresponding and the
corresponding output in Column 2.
Syntax Output
>plot sin(x)
gives a simple plot of sin(x)
(x
between - 10 £ x £ 10
-10
>plot
>plot
plot [
[-2*pi:2*pi][-
-2*
2*pi
pi:2
:2*p
*pi][-
*p
1.1:1.1]
1.1:
1.1:1.1]
1] sin(x)
sin(
sin(x)
n( x)
Sets the
Sets the range
ran
ange
an ge off the
e x and y-
y-
axes
ax es iin
n wh
whic
whichich in which
ic w ch the
function
func
fu nction
nc on sin(x)
sin
s in(x)) is to be plotted
in ed aand
nd
displayed
disp
spla
laye
la yed
yed thro
through
rough the
ro he
commands:
comm
co mmands
mm ds:: [-2*pi:2
ds [-2*pi:2*pi][-
:2*pi]
:2 i][
i] [-
1.1:1. 1] so that
1.1]
1.
1.1:1.1]
- 2p £ x £ 2p and - 1.1 £ y £ 1.1
> plot [-2*pi:2*pi][-
1.1:1.1] sin(x) plot [-
2*pi:2*pi][-1.1:1.1]
sin(x) with points
plots sin(x) in the range
- 2p £ x £ 2p , - 1.1 £ y £ 1.1
with points only through the
command
with points
32