1 A Portable Scientific Visualization Program: GnuPlot Asst. Prof. Emin Korkut.

Slides:



Advertisements
Similar presentations
Escape Sequences \n newline \t tab \b backspace \r carriage return
Advertisements

Methods Java 5.1 A quick overview of methods
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Arithmetic in Pascal (2) Arithmetic Functions Perform arithmetic calculations Gives an argument to the function and it returns the result.
Maths & Trig, Statistical functions. ABS Returns the absolute value of a number The absolute value of a number is the number without its sign Syntax ◦
Copyright © Cengage Learning. All rights reserved.
Tcl and Otcl Tutorial Part I Internet Computing KUT Youn-Hee Han.
Chapter 2 Basic Elements of Fortan
REVITALISE Visualization Tools Overview: gnuplot Garrett Love Shodor Education Foundation Durham, NC.
BIL101, Introduction to Computers and Information Systems Chapter 12 A Portable Scientific Visualization Program: GnuPlot Prepared by Metin Demiralp Istanbul.
FORTRAN.  Fortran or FORmula TRANslation was developed in the 1950's by IBM as an alternative to Assembly Language. First successfull high level language.
CSE4251 The Unix Programming Environment
Introduction to Matlab. Entering Commands Constants and Functions >> pi ans = >> eps ans = e-016 >> sin(pi/2) ans = 1 >> log(1000) ans =
1 Python Chapter 2 © Samuel Marateck, After you install the compiler, an icon labeled IDLE (Python GUI) will appear on the screen. If you click.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
1 CS101 Introduction to Computing Lecture 35 Mathematical Methods (Web Development Lecture 12)
Mathematics By: Andrew Reed-Stum. Equations Definition Equations- An expression or a proposition often algebraic, asserting the quantities.
1 Chapter 1 Preliminaries Functions and Their Graphs.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
An Introduction to Unix Shell Scripting
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) MATH Functions in C Language.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Fortran: Expressions and Assignments Session Two ICoCSIS.
Input, Output, and Processing
INTRODUCTION TO MATLAB LAB# 01
Class Review. Basic Unix Commands list files in a directory: ls list files in a directory: ls remove files: rm remove files: rm rename files: mv rename.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to Programming with RAPTOR
STROUD Worked examples and exercises are in the text PROGRAMME F10 FUNCTIONS.
Introduction to MATLAB ENGR 1181 MATLAB 1. Opening MATLAB  Students, please open MATLAB now.  CLICK on the shortcut icon → Alternatively, select… start/All.
Class Work Find the exact value of cot 330
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Visual Basic I Programming
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
C++ Programming Lecture 9 Functions – Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CSCI 125 & 161 / ENGR 144 Lecture 8 Martin van Bommel.
ENG 1181 First-Year Engineering Program College of Engineering Engineering Education Innovation Center First-Year Engineering Program MAT - Introduction.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Haskell Basics CSCE 314 Spring CSCE 314 – Programming Studio Using GHC and GHCi Log in to unix.cse.tamu.edu (or some other server) From a shell.
Section 1.5 Trigonometric Functions
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
Functions Venkatesh Ramamoorthy 21-March Examples #include double y ; … y = sin(45*3.1416/180) ; std::cout
Recursion It is a process of calling the same function itself again and again until some condition is satisfied. Syntax: func1() { ……….. func1(); }
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
 How many radians are in 180°?  How many degrees in 2π radians?  How many degrees in 1 radian?  Find sin 47°  Find sin 47. π or approximately 3 360°
Introduction to Gnuplot Bob Dowling University Computing Service.
Simple C Programs.
Some Useful MATLAB Functions
ECE 1304 Introduction to Electrical and Computer Engineering
Chapter 6 - Functions modular programming general function format
ECE 1304 Introduction to Electrical and Computer Engineering
Matlab Introduction.
BIL 104E Introduction to Scientific and Engineering Computing
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Terminal-Based Programs
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

1 A Portable Scientific Visualization Program: GnuPlot Asst. Prof. Emin Korkut

2 GNUPlot is an interactive function plotting program. It has interactive or batch modes. To invoke interactive mode it is sufficient to give the gnuplot command at the command prompt of linux. When this is done a prompt appears and prompts the user to give gnuplot commands. The commands of gnuplot may need parameters and arguments depending on what you want them to do. Gnuplot syntax is case sensitive. You can abbreviate the command names as long as the abbreviation is not ambiguous. Any number of commands may appear on a line, separated by semicolons (;). Strings are indicated with quotes. They may be either single or double quotation marks. You may extend the gnuplot commands over several input lines but for this purpose you must end each line except the last one with a backslash (\). The backslash must be the last character on each line.

3 Now we can start to plot functions. First we deal with the library functions and their combinations. Consider the following command gnuplot>plot sin(x)

4 As can be seen the display range is selected between -10 and 10 for the x axis and between -1 and 1 for the y axis. These are default values for the plotting range of the sine function. The default plotting range in vertical direction may vary depending on the function. Whereas the horizontal default range is always between -10 and 10. The default ranges can be changed by the user. For example plot [-5:5] sin(x) command selects the horizontal plotting range between -5 and 5. The specification of the horizontal range needs two numerical values for the beginning and the end points. They must be separated by colon and enclosed by the brackets. One or both of the numerical values can be skipped. In that case either left or right side of the colon will include nothing. If both of the numerical values is not given then inside of the brackets contains nothing. The display output of this command is given below

5

6 The ticks on the horizontal axis for this plot are positioned by gnuplot which has used an interval whose length equals 2 between ticks. This can be changed. For this we can modify the last example as follows set xticks 1 plot [-5:5] sin(x) where the interval between two consecutive ticks is set to 1. The resulting display is as follows.

7

8 The range for the vertical coordinates can also be set by the user. For this purpose we can use an additional pair of brackets. For example, the command plot [-5:5] [-2:2] sin(x) produces the following display output.

9 On the other hand the vertical tics can be controlled by using the set ytics command as done in the following sample command. set ytics 1 plot [-5:5] [-2:2] sin(x)

10 It is possible to plot more than one function at a single attempt. For this purpose the functions to be plotted must be given in comma separated form like the following command. set xtics 1; set ytics 1 plot [-5:5] [-2:2] sin(x), cos(x), tan(x) This plots the trigonometric functions, sine, cosine, and tangent and produces the following display output.

11

12 Comment In GNUPlot comments are created by using the character \#. This symbol can be positioned at the beginning of or somewhere else in a line. GNUPlot ignores the remaining portion of the line after this character. The effect of this character vanish between quotation marks, inside numbers and inside command substitutions. As a matter of fact it is alive anywhere it makes sense to work. Exit The commands exit and quit and the END-OF-FILE character exit GNUPlot. All these commands clear the output device before exiting.

13 Functions The functions in GNUPlot are the same as the corresponding functions in the Unix mathematics library, except that all functions accept integer, real, and complex arguments, unless otherwise noted. The sgn function is also supported, as in BASIC. * abs: The abs function returns the absolute value of its argument. The returned value is of the same type as the argument. For complex arguments, abs(x) is defined as the length of x in the complex plane [i.e., sqrt(real(x)**2 + imag(x)**2) ]. * acos: The acos function returns the arc cosine (inverse cosine) of its argument. acos returns its argument in radians. * arg: The arg function returns the phase of a complex number, in radians.

14 * asin: The asin function returns the arc sin (inverse sin) of its argument. asin returns its argument in radians. * tan: The atan function returns the arc tangent (inverse tangent) of its argument. atan returns its argument in radians. * ceil: The ceil function returns the smallest integer that is not less than its argument. For complex numbers, ceil returns the smallest integer not less than the real part of its argument. * cos: The cos function returns the cosine of its argument. cos expects its argument to be in radians. * cosh: The cosh function returns the hyperbolic cosine of its argument. * exp: The exp function returns the exponential function of its argument (e raised to the power of its argument).

15 * floor: The floor function returns the largest integer not greater than its argument. For complex numbers, floor returns the largest integer not greater than the real part of its argument. * imag: The imag function returns the imaginary part of its argument as a real number. * int: The int function returns the integer part of its argument, truncated toward zero. * log: The log function returns the natural logarithm (base e) of its argument. * log10: The log10 function returns the logarithm (base 10) of its argument. * real The real function returns the real part of its argument.

16 * sgn: The sgn function returns 1 if its argument is positive, -1 if its argument is negative, and 0 if its argument is 0. If the argument is a complex value, the imaginary component is ignored. * sin: The sin function returns the sine of its argument. sin expects its argument to be in radians. * sinh: The sinh function returns the hyperbolic sine of its argument. * sqrt: The sqrt function returns the square root of its argument. * tan: The tan function returns the tangent of its argument. tan expects its argument to be in radians. * tanh: The tanh function returns the hyperbolic tangent of its argument.

17 Operators The operators in GNUPlot are the same as the corresponding operators in the C programming language, except that all operators accept integer, real, and complex arguments, unless otherwise noted. The ** operator (exponentiation) is supported, as in FORTRAN. Parentheses may be used to change order of evaluation. The following is a list of all the binary operators and their usages:

18 *a*bmultiplication /a/bdivision % a%bmodulo +a+baddition -a-bsubtraction = a = = bequality ! =a! = binequality & a & & blogical AND | |a | | blogical OR where the factorial operator returns a real number to allow a greater range.

19 Help The help command displays on-line help. Load The load command executes each line of the specified input file as if it had been typed in interactively. Files created by the save command can later be loaded. Any text file containing valid commands can be created and then executed by the load command. Files being loaded may themselves contain load commands. The load command must be the last command on the line. The syntax of the command is load "inputfile". The name of the input file must be enclosed in (either single or double) quotes. The load command is performed implicitly on any file names given as arguments to GNUPlot. These are loaded in the order specified, and then GNUPlot exits.

20 plot [-20:20] sin(x), atan(x), cos(atan(x))

21 plot [-20:20] sin(30*x)*atan(x)

22 set parametric set dummy t set autoscale set title “t, sin(t)/t or sin(x)/x” plot t, sin(t)/t

23 set parametric set dummy t set autoscale set title “” plot sin(t)/t, t

24 set parametric set dummy t set autoscale set samples 160 set title “” plot sin(t), cos(t)

25 set parametric set dummy t set autoscale set xrange [-3:3] set yrange [-3:3] set title “Parametric conic sections” plot –t, t, cos(t), cos(2*t), 2*cos(t), sin(t), -cosh(t), sinh(t) set title “”

26 set parametric set dummy t set autoscale set xrange [-5:5] set yrange [-5:5] plot tan(t), t, t, tan(t)

27 set parametric set dummy t set autoscale set trange [ :3] plot t, log(t), -t, log(t), sin(t), t**2, -sin(t), t**2

28 set parametric set dummy t set autoscale set yrange [-1.5:1.5] set trange [0.0001:10*pi] plot sin(t)/t, cos(t)/t

29 set noborder set clip set polar set autoscale set xtics axis nomirror set ytics axis nomirror set zeroaxis set trange [0:2*pi] set title “Three circles (with aspect ratio distortion)” plot.5,1,1.5

30 set noborder set clip; set polar set xtics axis nomirror; set ytics axis nomirror set samples 160; set zeroaxis set trange [0:2*pi] set title “” plot cos(2*t)

31 set noborder set clip; set polar set xtics axis nomirror; set ytics axis nomirror set samples 160; set zeroaxis set trange [0:2*pi] set title “” plot 2*sqrt(cos(t)), -2*sqrt(cos(t))

32 set noborder set clip; set polar set xtics axis nomirror; set ytics axis nomirror set samples 160; set zeroaxis set trange [0:2*pi] plot sin(4*t), cos(4*t)

33 set samples 21; set isosamples 11 set xlabel “X axis” –3,-2; set ylabel “Y axis” 3,-2 set zlabel “Z axis” -5; set title “3D gnuplot demo” set label 1 “This is the surface boundary” at –10,-5,150 center set arrow 1 from –10,-5,120 to –10,0,0 nohead set arrow 2 from –10,-5,120 to 10,0,0 nohead set arrow 3 from –10,-5,120 to 0,10,0 nohead set arrow 4 from –10,-5,120 to 0,-10,0 nohead set xrange [-10:10]; set yrange [-10,10] splot x*y

34 set samples 21; set isosamples 11 set xrange [-10:10]; set yrange [-10,10] set grid splot x**2+y**2, x**2-y**2

35 set samples 21; set isosamples 11 set xrange [-10:10]; set yrange [-10,10] set ticslevel 0.0 set title “3D gnuplot demo (ticslevel = 0.0)” splot (x**3+y**3)/10

36 set samples 21; set isosamples 11 set xrange [-10:10]; set yrange [-10,10] set ticslevel 2.0 set title “3D gnuplot demo (ticslevel = 2.0)” splot (x**3+y**3)/10

37 set samples 21; set isosamples 11 set xrange [-10:10]; set yrange [-10,10] set grid set ticslevel 0.5 set title “3D gnuplot demo (ticslevel = 0.5)” splot (x**3+y**3)/10

38 set samples 21; set isosamples 11 set xrange [-10:10]; set yrange [-10,10] splot x*y with points

39 set xtics autofreq set ytics autofreq set xrange [-1:1]; set yrange [-1,1] set samples 51; set isosample 21 set dummy u,v; set title “3D gnuplot demo” splot u*v / (u**2+v**2+0.1)