gnu plot
DESCRIPTION
11TRANSCRIPT
OutlineBasics
Gnuplot
Kashyap Garimella
modified for CS2810 bySubhashini V
February 28, 2011
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
What can I do ?
I First of all we need to understand what we can do
I Drawing 2D plots
I Drawing 3D plots
I Polar coordinates
I Parametric functions
I Plotting Numeric data
I Other Miscellaneous Stuff
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Limitations
I Floating point exceptions
I Precision in time format
I Problems with 3D like rendering, etc
I ....
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Entering, getting help
I Entering gnuplot - type ”gnuplot” in terminal
I To get help on any topic, you can type ”help < topic >”
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Plotting functions
I Any mathematical expression accepted by C, FORTRAN,Pascal, or BASIC may be plotted. The precedence ofoperators is determined by the specifications of the Cprogramming language.
I help plot; help splot; help replot;
I plot - 2D, splot - 3D
I plot < function >
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Plotting functions addons
I help set; help reset;
I set options; set is used to set various options
I eg:
I set xrange [1,2];
I variables/parameters - a=1; b=a+1;
I eg:
I a=1; b=2; f(x)=ax+b; plot f(x);
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
set term
I help set term; read about png, ps, pdf
I eg:
I plot sin(x) with points pointtype 2;
I plot sin(x) with linepoints;
I other options - lines, dots, impulses, etc.
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Plotting data
I help plot datafile;
I help splot datafile;
I Data can taken from file or from stdin
I Data files should have the data arranged in columns ofnumbers. Columns should be separated by white space (tabsor spaces) only, (no commas). Lines beginning with a #character are treated as comments and are ignored byGnuplot.
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Plotting data contd.
I eg:
I plot ”force.dat” using 1:2 title ’Column’, ”force.dat” using 1:3title ’Beam’
I plot ”-” using 1:2 notitle with impulses; # data from stdin
I splot ”force.dat” using 1:2:3 with lines
I set datafile commentschars ”#
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
tics, grid, scripts etc
I The xtics command is enormously versatile and there areconvenient options for creating tic marks at regularincrements (regular multiples, in logarithmic scale), andspecial formats for time-related data.
I help xtics
I help mxtics
I gnuplot scripts. Eg: myscript.gnu; Run it by executing”gnuplot myscript.gnu”
I pause -1 # Wait until a carriage return is hit
I pause 3 # Wait three seconds
I pause -1 ”Hit return to continue”
I pause 10 ”Isn’t this pretty? It’s a cubic-spline.”
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Example 1 Bargraphs
I bargraph.gnu
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Curve fitting
I help fit
I example:
I f 1(x) = a1 ∗ tanh(x/b1) # define the function to be fit
I a1 = 300; b1 = 0.005; # initial guess for a1 and b1
I fit f1(x) ’force.dat’ using 1:2 via a1, b1
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Example 2 Curve fitting
I fitting.gnu
Kashyap Garimella Gnuplot
OutlineBasics
IntroductionBasic commands
Calling gnuplot from within a python script
I runtest.pl
Kashyap Garimella Gnuplot