1 / 25

BIL101, Introduction to Computers  and  Information Systems Chapter 12

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.

urit
Download Presentation

BIL101, Introduction to Computers  and  Information Systems Chapter 12

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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.

  3. To invoke interactive mode it is sufficient to give the GnuPlotcommand 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.)

  4. 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.

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

  6. 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, • 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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)

  11. 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)

  12. 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.

  13. 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.

  14. 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.

  15. 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.

  16. *atan: The atan function returns the arc tangent (inverse tangent) of its argument. atan returns its argument in radians. • ceil: The ceil functionreturns 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.

  17. * 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. * 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.

  18. * 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.

  19. 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.

  20. 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.

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

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

  23. 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.

  24. 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.

  25. 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.

More Related