Title: BIL101 Introduction to Computers and Information Systems
1BIL101 Introduction to Computers and Information
Systems
A Portable Scientific Visualization Program
GNUPLOT
Turgut Yilmaz Office 244 e-mail
turgut.yilmaz_at_itu.edu.tr www.mkn.itu.edu.tr/yilma
ztur
Presentation file prepared by Murat
Çakan cakanmu_at_itu.edu.tr Modified by T. Yilmaz
(2003)
2BIL101 Introduction to Computers and Information
Systems
Gnuplot is an interactive function plotting
program. It comes with almost all distributions
of Linux Systems To invoke Gnuplot type
Gnuplot at the command prompt of Linux To end
Gnuplot type quit or exit
3BIL101 Introduction to Computers and Information
Systems
- Gnuplot is case sensitive!
- Any number of command may appear on
- a line seperated by semicolons()
- Strings are indicated with quotes
- Commands may be extended to several lines for
this you must end each line with a Backslash (\)
4BIL101 Introduction to Computers and Information
Systems
- Gnuplot functions
- abs absolute value of its argument
- acos returns arc cosine of its argument
- asin returns arc sine of its argument
- atan returns arc tangent of its argument
- cos returns the cosine of its argument
- cosh returns the hyperbolic cosine of its
argument - exp returns the exponential function of its
argument - log returns the natural logarithm (base e) of
its argument - log10 returns the logarithm (base 10) of its
argument
5BIL101 Introduction to Computers and Information
Systems
- Gnuplot functions(continued)
- sgn returns 1 if its argument is positive, -1
if negative and 0 if 0 - sin returns the sine of its argument
- sinh returns the hyperbolic sine of its
argument - sqrt returns the square root of its argument
- tan returns the tangent of its argument
- tanh returns the hyperbolic tangent of its
argument
6BIL101 Introduction to Computers and Information
Systems
Gnuplot operators Symbol Example Explanation
ab exponentiation ab multiplication
/ a/b division ab modulo ab ad
dition - a-b subtraction a
b equality ! a!b inequality
7BIL101 Introduction to Computers and Information
Systems
Two dimesional plot command is plot Three
dimensional plot command is splot The documents
for GNUPlot is accesible via web site of ITÜ
Informatics Institute
8BIL101 Introduction to Computers and Information
Systems
EXAMPLES Program I plots the sine function via
the following display output gtplot sin(x)
Default range. Subject to modification
9BIL101 Introduction to Computers and Information
Systems
gtplot -55 sin(x)
New range -5 5
10BIL101 Introduction to Computers and Information
Systems
To set the interval between two consecutive ticks
in x-direction to 1 gtset xtics 1 gtplot -55
sin(x)
11BIL101 Introduction to Computers and Information
Systems
To use no tics at all in x-direction gtset
xtics 0 gtplot -55 sin(x)
12BIL101 Introduction to Computers and Information
Systems
To plot several functions on the samegraph gtset
xtics 1 set ytics 1 gtplot -55 -22 sin(x),
cos(x), tan(x)
13BIL101 Introduction to Computers and Information
Systems
How to plot user defined functions of single
variable? Set axis range(s), define function and
use this function in the plot command Example gt
set xrange-1010 gtset yrange-1010 gt
y(x)2x5 gtset grid gtplot y(x)
14BIL101 Introduction to Computers and Information
Systems
How to plot user defined functions two
variables? Set axis range(s), define function and
use this function in the plot command Example gt
set xrange-1010 gtset yrange-1010 gt
z(x,y)2x3-y2 gtset grid gtsplot z(x,y)