gnuplot basics
Best, simplest, very powerful plotter (and more)
Can easily plot formulas or data_files or both!
few plotters can do it so simply!
gnuplot> plot "File" will plot column 1 as x , col 2 as y
of a file named "File"
or can specify which columns of multicolumn file:
gnuplot> plot "File" u 3:1 w lines lt 1 lw 2
will plot using column 3 as x and 1 as y
with lines, in red (lt 1), line_width 2
Can plot formulas directly:
gnuplot> R(x) = 1/(1+x**2)
formula to plot (Runge function)
gnuplot> plot R(x) default xrange is [-10:10]
Can specify desired xrange [-5:5] , in blue (lt 3), lw 4:
gnuplot> plot [-5:5] R(x) lt 3 lw 4
Can plot several graphs on same plot:
formulas, and/or formulas and files:
use comma in-between: plot "file" , R(x) , ... e.g.
gnuplot> G(x) = exp(-x**2)
another formula to plot (Gaussian, bell curve)
gnuplot> plot R(x) , G(x) (on default xrange, default colors)
Better: specify xrange, colors, line_widths:
gnuplot> plot [-5:5] R(x) lt 1 lw 3, G(x) lt 2 lw 4
Set/unset xrange , yrange : on plot line:
gnuplot> plot [-5:5] [-0.2:1.2] R(x) lt 1 lw 3 , G(x) lt 2 lw 4
or each one separately:
gnuplot> set xrange [-6:6] ; plot R(x) lt 1 lw 3, G(x) lt 2 lw 4
gnuplot> set yrange [-0.1:1.1] ; plot R(x) lt 1 lw 3, G(x) lt 2 lw 4
gnuplot> unset yrange ; replot
Set xlabel, ylabel, title:
gnuplot> set xlabel 'x' ; set ylabel 'y'
gnuplot> set title 'Runge R(x) and Gaussian G(x)'
gnuplot> replot (re-plot last plot)
See links on course page for more...