GNUPLOT
Quick Guide
ELECTGON
www.electgon.com
ma_ext@gmx.net
21.06.2018
Contents
1 Installing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Launch Gnuplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 Plotting Data From File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Gnuplot 1. Installing
1 Installing
Install gnuplot in linux using
$sudo apt-get install gnuplot
the following package is also needed to display output graphs
$sudo apt-get install gnuplot-x11
2 Launch Gnuplot
In terminal window type gnuplot. There are some de ined functions in gnuplot that you can
work with directly.
Function Returns
abs(x) absolute value of x, |x|
acos(x) arc‐cosine of x
asin(x) arc‐sine of x
atan(x) arc‐tangent of x
cos(x) cosine of x, x is in radians.
cosh(x) hyperbolic cosine of x, x is in radians
erf(x) error function of x
exp(x) exponential function of x, base e
inverf(x) inverse error function of x
invnorm(x) inverse normal distribution of x
log(x) log of x, base e
log10(x) log of x, base 10
norm(x) normal Gaussian distribution function
rand(x) pseudo‐random number generator
sgn(x) 1 if x > 0, ‐1 if x < 0, 0 if x=0
sin(x) sine of x, x is in radians
sinh(x) hyperbolic sine of x, x is in radians
sqrt(x) the square root of x
tan(x) tangent of x, x is in radians
tanh(x) hyperbolic tangent of x, x is in radians
Bessel, gamma, ibeta, igamma, and lgamma
functions are also supported. Many functions
can take complex arguments. Binary and unary
operators are also supported.
Table 1: Prede ined Gnuplot Functions [1]
So you can use any of these functions to make operations or to plot it.
$gnuplot> plot sin(x)/x
this will plot sin(x)/x with x has default range values [‐5:5] to draw for another range type
$gnuplot> plot [-15:15] sin(x)/x
you can control range of display graph by de ining it as:
3
Gnuplot 3. Plotting Data From File
$gnuplot> set xrange [0:5]
$gnuplot> set yrange [-1:1]
$gnuplot> replot
3 Plotting Data From File
Assume you have the following data is stored in a text ile called data.txt
1 30
2 35
3 40
4 45
5 50
6 55
7 60
8 65
9 70
10 75
11 80
12 85
To plot this data type
$gnuplot> plot “data.”txt using 1:2 with steps
Where data.txt is the ile that contains this data, using 1:2 tells the gnuplot to draw
column 2 against column 1, with steps this to draw it as shown in steps; other options is
with lines or with dots or with points or with impulses.
4
Gnuplot 3. Plotting Data From File
Figure 1: Plot File Data
You can display the grid by
$gnuplot> set grid
Or you can also display grid at subvalues using
$gnuplot> set mxtics 5
$gnuplot> set mytics 5
$gnuplot> set grid xtics ytics mxtics mytics
To erase it
$gnuplot> set grid noxtics noytics
5
Bibliography
[1] http://people.duke.edu/~hpgavin/gnuplot.html
[2] https://web.archive.org/web/20121029110317/http://t16web.lanl.gov/Kawano/gnuplot
/index‐e.html