Sie sind auf Seite 1von 5

GNUPLOT VIVA QUESTIONS

1. Question 1. What Is Gnuplot?


Answer :
o Gnuplot is an interactive plotting program that is command based.
o It is used for plotting functions and data points in 2D and 3D plots.
o Gnuplot supports many formats of data points and functions.
o It is primarily used for displaying scientific data .
o It supports 3D data points and surfaces in various styles like contour plot, mesh etc.
2. Question 2. Which Plat From Supports Gnuplot?
Answer :
o Gnuplot supports various OS platforms including Windows, Linux, Unix, OSX.
o Current version supports even on older operating systems such as MS-
DOS,KAmiga, OS-9/68k, Atari ST.
o The legacy architecture platforms support versions below 4.0
o Gnuplot is a freeware authored by freelance authors, volunteers.
o The compilation of Gnuplot script is different for individual operating systems.
Question 3. Explain About Gnuplot Functionality?
Answer :
Following is the functionality of gnuplot.
o Two-dimensional functions and data points plotting.
o Three-dimensional data points and surfaces plotting in contour and mesh styles.
o Computing algebraic expressions in integer, float and complex arithmetic.
o User defined hot keys.
o Extensive online help.
o Gnuplot supports TEX-like text formatting for data points, axes, titles and labels.
o Command line editing in user friendly manner.
Question 4. How To Change Symbol Size, Line Thickness And The Like In Gnuplot?
Answer :
o Various commands are available to assign line and point properties.
o These properties include color, thickness, shape of point etc.
o The command test displays a test page for the selected terminal type.
o The test page shows all available pre-defined combinations of colors, size and shapes.
o The command ‘set style’ is used to define the combinations.
Question 5. How To Animate In Gnuplot?
Answer :
o Animated graphs are a set of plots.
o These graphs are available in suitable formats.
o Version gd 2.0.29 or later supports direct generation of an animated GIF.
o Scripts can be written to generate output of GIF files.
o The generated animated GIF files can be executed in animators such as ‘gifsicle’.
o The ‘mpeg_encode’ command encodes the sequences of images into mpeg format
movies.
Question 6. How To Generate Plots In Gif Format?
Answer :
o GIF format support is provided by external library of Gnuplot.
o One such library is ‘libgd’.
o Versions 1.2 to 1.4 of libgd produces only GIF output.
o Versions 1.6 to 2.0.27 supports PNG outputs.
o Version 2.0.28 of Boutell gd library restored the support of GIF functionality.
o To get the support of GIF, gnuplot need to be linked with any compatible gd library.
Question 7. How To Include Gnuplot Graphs In Word Processor?
Answer :
o Usually, save a plot to a word processor format that gnuplot understands.
o Read the plot from the word processor.
o Vector formats like PostScript, pdf, TEX,LATEX etc. are preferred.
o Vector formats supports scaling the graph later to the correct size.
o Use ‘set term’ to get available file format list.
o It is suggested to check and correct the bounding box of the graphs in ‘eps’ file format.
o Use GSView viewer for previewing the image box.
Question 8. How To Print Out Graphics In Gnuplot?
Answer :
o To print graph, ‘set terminal’ is used.
o For example, ‘set terminal postscript’ produces the graph in PostScript format.
o The out put can be redirected by using ‘set output’ command.
The following script allows to produce output of a graph sin(x) in PostScript format:
gnuplot> plot [-6:6] sin(x)
gnuplot> set terminal postscript
gnuplot> set output "sin.ps"
gnuplot> replot
Question 9. Is Gnuplot Suitable For Scripting?
Answer :
o Yes. Gnuplot is suitable for scripting.
o The scripts can be read by gnuplot during an interactive session.
o It also runs in batch mode.
o Running in batch mode is done by piping a pre-existing file.
o A stream of commands can also be sent to stdin, to run in batch mode.
o Packages such as Octave is easily wrapped in a cgi script to be used as a web-driven
plot generator.
Question 10. Why The Origin Of Z-axis Is Not On The Xy-plane?
Answer :
o The zero-point of Z-axis is placed above the XY plane of splot.
o ‘set ticslevel’ is used to move this origin onto the XY plane.
o By setting ticslevel=0, the zero of Z-axis moves onto the XY plane.
o The following is the script to do this:
gnuplot> set ticslevel 0
gnuplot> splot (x**2)*(y**2)
Question 11. How To Change Contours In Gnuplot?
Answer :
o Contours are controlled by the command ‘set cntrparam’.
o Following example illustrates change of contours:

gnuplot> set contour


gnuplot> set cntrparam levels 12
gnuplot> set cntrparam levels incremental -1, 0.2, 1
gnuplot> set cntrparam levels discrete -0.2, -0.5, 0.2, 0.5

o The key world ‘levels’ defines the levels of drawn contour curves.
o In the above example, levels 12 indicates that twelve contour lines are drawn.
o Incremental defines the initial value, increment value and the final value.
o A legend for contour lines is available in the legend graph.
Question 12. How To Make Surface Mesh Finer?
Answer :
o The mesh size, indicated by XY coordinates is determined by ‘isosample’.
o The default number is 10.
o To get the finer mesh the size should be more.
o The mesh size troubles when a hidden line option is used with ‘set hidden3d’.
o To avoid these troubles, make ‘isosample’ larger, like 30 and above.
Question 13. How To Plot Implicit Defined Graphs?
Answer :
o Implicit graphs are plotted indirectly.
o The following example illustrates the process:
gnuplot>
gnuplot> function(x,y) = y - x**2 / tan(y)
gnuplot> set contour base
gnuplot> set cntrparam levels discrete 0.0
gnuplot> unset surface
gnuplot> set table 'graphcurves.dat'
gnuplot> splot function(x,y)
gnuplot> unset table
gnuplot> plot 'graphcurves.dat' w l

o The function() sets the coordinates.


o The contour graph is defined in ‘graphcurves.dat’ file.
o ‘splot’ executes the function.
o ‘plot’ places the graph in the file ‘graphcurves.dat’ file.
Question 14. How To Fill An Area Between Two Curves?
Answer :
o A pseudo file ‘+’ is used to fill the area between two curves.
o The option ‘filledcurves’ closed is used.
o The following example demonstrates the process. The two curves are f(x) and g(x).
f(x)=cos(x)
g(x)=sin(x)
xmax=pi/4
set xrange [0:xmax]
plot '+' using 1:(f($1)):(g($1)) with filledcurves closed
Question 15. How To Include Accented Characters?
Answer :
o 8 bit character codes are used to obtain accented characters.
o Example of accented character is ü
o Following is an example to include accented characters:
gnuplot> set encoding iso_8859_1
gnuplot> set title "M374nchner Bierverbrauch 374ber die Jahre"
gnuplot> plot "bier.dat" u 1:2
o Like wise, characters in Czech, French, Russia characters can be types using set
encoding.
o Two or more encoding characters can not be mixed in one file. Ex. accents for west
and east latin encodings.
o UTF-8 encoding fonts can be a general solution.
Question 16. How To Plot Two Functions In Non-overlapping Regions?
Answer :
o Parametric plot can be used to plot 2 functions in non-overlapping regions.
o Following examples illustrates:
gnuplot> set parametric
gnuplot> aaf=1
gnuplot> bb=3
gnuplot> cc=2
gnuplot> dd=4
gnuplot> x1(t) = aa+(bb-aa)*t
gnuplot> x2(t) = cc+(dd-cc)*t
gnuplot> f1(x) = sin(x)
gnuplot> f2(x) = x**2/8
gnuplot> plot [t=0:1] x1(t),f1(x1(t)) title "f1", x2(t), f2(x2(t)) title "f2"
o The last line of code is parametric plot that plots the functions x1 and f1, x2 and f2.
Question 17. How To Produce Graph Of An Exact Border Size?
Answer :
o Position the top, left, bottom, right borders in fractional position within the page.
o The following script set the exact border size.
set lmargin at screen 0.05
set bmargin at screen 0.05
set rmargin at screen 0.95
set tmargin at screen 0.95
Question 18. How To Fix The Bug Of Partial Displaying Of Output Files?
Answer :
o Flush the output with a closing set output.
o Certain output formats like PostScript, PDF,Latex, etc., places many pages in a single
resultant file.
o The file remains open after every plot by gnuplot. So that additional plots can be
added to it.
o The file is available to the external applications as it is in open state.
o As the files are open and remain unclosed, the partial output is plotted.
o To avoid the issue, specify the term for a plot using ‘set term’.
1. Question 19. How To Call Gnuplot In A Pipe Or With A Gnuplot-script Doesn't
Produce A Plot?
Answer :
Gnuplot can be called by using a perl script.
Following script illustrates:
#!/usr/local/bin/perl -w
open (GP, "|/usr/local/bin/gnuplot -persist") or die "no gnuplot";
# force the buffer to flush after every write
use FileHandle;
GP->autoflush(1);
print GP,"set term x11;plot '/tmp/data.dat' with linesn";
close GP
2. Question 20. How To Plot A Vertical Line?
Answer :
There are 3 alternatives to plot a vertical line using Gnuplot.
o A vertical line can be plotted using ‘set arrow ….. nohead’.
- The start and end points of an arrow need to be explicitly computed.
o Other alternative is to generate the in lined data points and plot them.
o Another process is to use parametric mode of gnuplot.
Question 18. How To Fix The Bug Of Partial Displaying Of Output Files?
Answer :
o Flush the output with a closing set output.
o Certain output formats like PostScript, PDF,Latex, etc., places many pages in a single
resultant file.
o The file remains open after every plot by gnuplot. So that additional plots can be
added to it.
o The file is available to the external applications as it is in open state.
o As the files are open and remain unclosed, the partial output is plotted.
o To avoid the issue, specify the term for a plot using ‘set term’.

Das könnte Ihnen auch gefallen