BIL101, Introduction to Computers and Information Systems Chapter 12 A Portable Scientific Visualization Program: GnuPlot Prepared by Metin Demiralp Istanbul.

Slides:



Advertisements
Similar presentations
2.1 Program Construction In Java
Advertisements

Methods Java 5.1 A quick overview of methods
Functions. COMP104 Functions / Slide 2 Introduction to Functions * A complex problem is often easier to solve by dividing it into several smaller parts,
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Tcl and Otcl Tutorial Part I Internet Computing KUT Youn-Hee Han.
BIL101, Introduction to Computers and Information Systems Chapter 11 Sample SQL Applications Prepared by Metin Demiralp Istanbul Technical University,
The scanf Function The scanf function reads input from the standard input device into one or more variables Example: scanf(“%lf”, &miles); Reads a real.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Expressions and Operators Program Style.
Chapter 2 Basic Elements of Fortan
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
FORTRAN.  Fortran or FORmula TRANslation was developed in the 1950's by IBM as an alternative to Assembly Language. First successfull high level language.
Introduction to C Programming
1 A Portable Scientific Visualization Program: GnuPlot Asst. Prof. Emin Korkut.
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.
Expressions and Interactivity Chapter 3. 2 The cin Object Standard input object Like cout, requires iostream file Used to read input from keyboard Often.
EG280 - CS for Engineers Chapter 2, Introduction to C Part I Topics: Program structure Constants and variables Assignment Statements Standard input and.
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
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.
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Computer Science 111 Fundamentals of Programming I Basic Program Elements.
Haskell. 2 GHC and HUGS Haskell 98 is the current version of Haskell GHC (Glasgow Haskell Compiler, version 7.4.1) is the version of Haskell I am using.
ENG 1181 College of Engineering Engineering Education Innovation Center MATLAB is a powerful program for numerical computations, plotting and programming.
Introduction to MATLAB ENGR 1181 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Input, Output, and Processing
INTRODUCTION TO MATLAB LAB# 01
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
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.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
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.
MATLAB Constants, Variables & Expression Nafees Ahmed Asstt. Professor, EE Deptt DIT, DehraDun.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Definition of the Programming Language CPRL
ECE 1304 Introduction to Electrical and Computer Engineering
Topics Designing a Program Input, Processing, and Output
Chapter 2: Introduction to C++
BIL 104E Introduction to Scientific and Engineering Computing
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Chapter 2: Introduction to C++
Arithmetic operations, decisions and looping
Introduction to MATLAB
Introduction to Matlab
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Terminal-Based Programs
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

BIL101, Introduction to Computers and Information Systems Chapter 12 A Portable Scientific Visualization Program: GnuPlot Prepared by Metin Demiralp Istanbul Technical University, Informatics Institute, Maslak { 80626, Istanbul, Türkiye) Version 0. 60

A Portable Scientific Visualization Program: GnuPlot  The subject is mostly aimed at the scientific visualization. Since GNUPlot is one of the most powerful and easily accessible world wide used free scientific visualization program we concern with it. GNUPlot are come with almost all distributions for also Windows and some other operating systems.  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 (commands and function names written in lowercase are not the same as those written in capital letters.)

 You can abbrivate 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 and each line except the last one with a backslash (\). The backslash must be the last character on each line.

 In this display output, 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. We can start to plot functions. First we deal with the library functions and their combinations. Consider the following command plot sin (x) This command plots the sine function.

 The specification of the horizontal range needs two numerical values for the beginning and the end points. plot [-5:5] sin (x) command selects the horizontal plotting range between -5 and 5. 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,

 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, the ticks on the horizontal axis 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 xtics 1 plot [-5:5] sin (X) where the interval between two consecutive ticks is set to 1.

If the ticks on the x axis are not desired then it is sufficient to use the command set xtics 0. Since the distance between two consecutive ticks are set to zero the ticks are accumulated at the leftmost bottom corner of the frame.

 This means the nonexistence of the ticks on the horizontal axis.  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)

 On the other hand the vertical ticks 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) 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 xticks 1; set ytics 1 plot [-5:5] [-2:2] Sin (x), Cos (x), tan (x)

 This plots the trigonometric functions, sine, cosine, and tangent. We can mention about some other features of GNUPlot. 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. The commands exit and quit and the END-OF-FILE character exit GNUPlot. All these commands clear the output device before exiting.

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.

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. 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. * asin: The asin function returns the arc sin (inverse sin) of its argument. Asin returns its argument in radians.

*atan: 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. ceil: The ceil function returns the smallest integer that is not less than 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. * 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). * floor: The floor function returns the largest integer not greater than its argument. * imag: The imag function returns the imaginary part of its argument as a real number. * 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. * 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.

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. Parantheses may be used to change order of evaluation.

The following is a list of all the binary operators and their usages: Symbol Example Explanation ** a**b exponentiation * a*b multiplication * a*b multiplication / a/b division / a/b division % a%b modulo % a%b modulo + a+b addition + a+b addition - a-b subtraction - a-b subtraction == a==b equality == a==b equality != a!=b inequality != a!=b inequality && a&&b logical AND && a&&b logical AND ll allb logical OR ll allb logical OR where the modulo, logical AND and logical OR requires integer arguments. where the modulo, logical AND and logical OR requires integer arguments.

The following is a list of all the unary operators and their usages: Symbol Example Explanation - -a unary minus - -a unary minus ! !a logical negation ! !a logical negation ! a! factorial ! a! factorial where the factorial operator returns a real number to allow a greater range.

Help The help command displays on-line help. To specify information on a particular topic use the syntax: help topic. If topic is not specified, a short message is printed about GNUPlot. After help for the requested topic is given, help for a subtopic may be requested by typing its name, extending the help request. After that subtopic has been printed, the request may be extended again, or simply pressing return goes back one level to the previous topic. Eventually, the GNUPlot command line will return.

Load The load command executes each line of the specified input file as if it had been typed in interactively. Files creates 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 inputfile must be enclosed in (either single or double) quotes. The load command executes each line of the specified input file as if it had been typed in interactively. Files creates 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 inputfile 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. This informations about two dimensional plotting seem to be sufficient for a beginner to GNUPlot. The three dimensional plotting command is splot and it is quite similar to the plot command.