gnuplot demo Kawano's Gnuplot Tutorial gnuplot 3.5 User's Guide
The order of arguments is important. eg notitle after using .
plot 'myfile.txt' using 1:2
-each line contains x y pair eg
0.0 0.0
0.5 0.25
1.0 1.0
set output 'myfile.ps'
replot
$ lpr myfile.ps
set terminal x11
set output
replot
q - to kill plot
Points can be displayed with
smooth csplines
with points
with lines
with lp
plot [0:] [0:] 'myfile.txt' using 1:2 smooth csplines notitle
-sets axes to include the origin
set nokey
set noxtics - turns of x-axis tics
set noytics
set noborder
plot "data.txt" using (log($1)):(log($2)) smooth csplines notitle
- quadratic data gives straight line with gradient of 2.
Multiple plots
gnuplot>
plot "results2.txt" using ($1):($2) notitle, "results2.txt" using ($1):($2) smooth csplines notitle
gnuplot>
plot "results2.txt" using (log($1)):(log($2)) notitle, "results2.txt" using (log($1)):(log($2)) smooth csplines title "log log graph"
To run a script file interactively use the load command.
load 't6.txt'
The quotes are necessary.
Script file gnup01.txt
$ gnuplot gnup01.txt where
the script file is given below. As this is ment not to be used
in interactive mode the output was set to the graphics file.
set term postscript set output "output1.ps" f(x) = exp(-x**2) plot [0:0.3] f(x)
The file needs to be viewed with a postscript editor. An alternative is this hack to both print and view your results.
f(x) = exp(-x**2) plot [0:0.3] f(x) pause -1 set term postscript set output "output1.ps" replot
gnuplot can be used as a calculator.
gnuplot> print pi
3.14159265358979
gnuplot> print 34%5
4
Parametric curves have dummy variable t.
set parametric
plot sin(t), cos(t)
set noparametric
3D plotting
For 3D x y z pair
splot 'myfile3D' using 1:2:3
gnuplot> splot [-3:3] [-3:3] x**2*y