plot
Plotting Functions : samples
gnuplot> plot sin(x)/x
gnuplot> plot [0:5] sin(x)
gnuplot> splot sin(x*y/20)
gnuplot> plot sin(x) title 'Sine Function', tan(x) title 'Tangent'
gnuplot> set title "Hello World"
gnuplot> replot
gnuplot> set polar
gnuplot> plot sin(t)
gnuplot> set xlabel "x"
gnuplot> set ylabel "y"
gnuplot> replot
gnuplot> set xrange [-pi:pi]
gnuplot> plot sin( x) w l ls 1, sin(2*x) w l ls 2, \
sin(3*x) w l ls 3, sin(4*x) w l ls 4, \
cos( x) w l ls 5, cos(2*x) w l ls 6, \
cos(3*x) w l ls 7, cos(4*x) w l ls 8
Define a function and plot
f(x)=sin(x)*cos(x)
gnuplot> a=0.25
gnuplot> b=0.02
gnuplot> c=0.05
gnuplot> d=0.1
gnuplot> f(x)=c/((x-a)*(x-a)+b)+d/sqrt(x)
gnuplot> set xrange [0:1]
gnuplot> set yrange [0:4]
gnuplot> plot f(x)
gnuplot> print f(0.4)
Plotting File
gnuplot>plot "file.int" w l
from a file having multiple column
gnuplot> plot "file1.int" using 1:2 title 'Column', "file1.int" using 1:3 title 'Beam'
What if we want to plot one_column against the another_colum, using the sm_other_column an error bar
gnuplot> plot 'file.int' using another_colum:one_column:sm_other_column with yerror
To plot the first two columns from multiple columns in a file
gnuplot> plot 'file1.int' using 1:2
from multiple files
gnuplot> plot "file1.int" using 1:2 title 'int file 1', \"file2.dat" using 1:3 title 'int file 2'
plot command customization
gnuplot> plot "file1.int" using 1:2 title 'Column' w l , "file1.int" using 1:3 title 'Beam' w lp
Create a title: > set title "My good name is Don "
Put a label on the x-axis: > set xlabel "Age(years)"
Put a label on the y-axis: > set ylabel "Achivements(fine in $)"
Change the x-axis range: > set xrange [1:30]
Change the y-axis range: > set yrange [500:5000]
Have Gnuplot determine ranges: > set autoscale
Move the key: > set key 0.01,100
Delete the key: > unset key
Put a label on the plot: > set label "Most successful time" at 18,1000
Remove all labels: > unset label
Plot using log-axes: > set logscale
Plot using log-axes on y-axis: > unset logscale; set logscale y
Change the tic-marks: > set xtics (1,5,10,15,20)
Return to the default tics: > unset xtics; set xtics auto
GNUPLOT SCRIPTS
set autoscale # scale axes automatically
unset log # remove any log-scaling
unset label # remove any previous labels
set xtic auto # set xtics automatically
set ytic auto # set ytics automatically
set title "Force Deflection Data for a Beam and a Column"
set xlabel "Deflection (meters)"
set ylabel "Force (kN)"
set key 0.01,100
set label "Yield Point" at 0.003,260
set arrow from 0.0028,250 to 0.003,280
set xr [0.0:0.022]
set yr [0:325]
CURVE-FITTING
f1(x) = a1*tanh(x/b1) # define the function to be fit
a1 = 300; b1 = 0.005; # initial guess for a1 and b1
fit f1(x) 'file.int' using 1:2 via a1, b1
to plot sin( column3 + column1 ) vs. 3 * column2 type:
gnuplot>plot 'file.int' using (3*$2):(sin($3+$1))
MULTI-PLOT: plot more than 1 graph in same window
set multiplot; # get into multiplot mode
set size 1,0.5;
set origin 0.0,0.5; plot sin(x);
set origin 0.0,0.0; plot cos(x)
unset multiplot # exit multiplot mode
adjust range
gnuplot> set xrange [0.01:20]
gnuplot> set yrange [0:2]
gnuplot> set logscale x
gnuplot> replot
Put Graduations
gnuplot> set ytrics 0
gnuplot> set mytics 10
gnuplot> set grid
gnuplot> replot
3d plots
gnuplot> set ticslevel 0
gnuplot> splot (x**2)*(y**2)
fine plot
gnuplot> set isosample 40
contour
gnuplot> set contour
gnuplot> set cntrparam levels 10
gnuplot> set cntrparam levels incremental -1, 0.2, 1
gnuplot> set cntrparam levels discrete -0.2, -0.5, 0.2, 0.5
gnuplot> set pm3d at b
gnuplot> set ticslevel 0.8
gnuplot> set isosample 40,40
gnuplot> splot x*x*exp(-x*x)*y*y*exp(-y*y)
colored
gnuplot> set xrange [-2:2]
gnuplot> set yrange [-2:2]
gnuplot> set pm3d
gnuplot> splot exp(-x*x)*exp(-y*y)
gnuplot> set term postscript eps enhanced color
gnuplot> set output "color.eps"
gnuplot> replot
gnuplot> set term postscript eps enhanced monochrome
gnuplot> set output "mono.eps"
gnuplot> replot
psudo 3d
gnuplot> set hidden3d
gnuplot> splot "file.int" w l
gnuplot> set pm3d
gnuplot> splot "test.dat" with pm3d
Polar Coordinate(plot with impulse: for nice view)
gnuplot> set polar
dummy variable is t for curves
gnuplot> set angles degrees
gnuplot> plot "file.int" with lines
gnuplot> set grid polar
plot (2 * t)
plot cos(2 * t)
plot cos(2 * t) w i ,2*t w l(change integer parameters)
plot cos(2*t)w i ,.5*t w i, t*t*.1 w i, t*t*t*.01 w i
Parameters
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> const=3
gnuplot> set trange [1:4]
gnuplot> set xrange [0:5]
gnuplot> set yrange [0:5]
gnuplot> plot const,t
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> set size square
gnuplot> set xrange [-1:1]
gnuplot> set yrange [-1:1]
gnuplot> plot [0:2*pi] sin(t),cos(t)
spiral
gnuplot> set xrange [-10*pi:10*pi]
gnuplot> set yrange [-10*pi:10*pi]
gnuplot> plot [0:10*pi] t*sin(t),t*cos(t)
Cardioid
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> r(t) = 1+cos(t)
gnuplot> plot [0:2*pi] r(t)*cos(t),r(t)*sin(t)