gnuplot demo Kawano's Gnuplot Tutorial gnuplot 3.5 User's Guide
The order of arguments is important. e.g. 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
gnu001.txt
$ gnuplot gnup001.txt
As this is ment not to be used
in interactive mode the output was set to the graphics file
and needs to be viewed with a postscript viewer.
set term postscript
set output "gnup001.ps"
f(x) = exp(-x**2)
plot [0:0.3] f(x)
Script file
gnu002.txt
$ gnuplot gnup002.txt
The file needs to be viewed with a postscript editor. An alternative both print and view your results.
f(x) = exp(-x**2)
plot [0:0.3] f(x)
pause -1
set term postscript
set output "gnup002.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
~/.gnuplot
set term x11