0% found this document useful (0 votes)
16 views24 pages

136_gnuplot_ass1n2

The document contains a series of gnuplot commands and their corresponding outputs, demonstrating various plotting techniques and functions. It includes exercises and factsheets that cover topics such as setting ranges, plotting functions, fitting data, and customizing graph appearances. The content is structured to provide practical examples for users to learn and apply gnuplot effectively.

Uploaded by

Subhodeep Chanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views24 pages

136_gnuplot_ass1n2

The document contains a series of gnuplot commands and their corresponding outputs, demonstrating various plotting techniques and functions. It includes exercises and factsheets that cover topics such as setting ranges, plotting functions, fitting data, and customizing graph appearances. The content is structured to provide practical examples for users to learn and apply gnuplot effectively.

Uploaded by

Subhodeep Chanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Name: Sirsha Dutta

Semester: 1
Roll Number: 136
Gnuplot Assignments 1 and 2
Factsheet 1
Fact 1:
Input:
gnuplot> f(x)=sin(x)+cos(x)*exp(-x)
gnuplot> plot f(x)
Output:

Fact 2:
Input:
gnuplot> f(x)=sin(x)
gnuplot> g(x)=cos(x)
gnuplot> plot f(x),g(x)
Output:
Fact 3:
Input:
gnuplot> set xrange [0:1]
gnuplot> set yrange [0:1]
gnuplot> plot sin(x)
Output:

Fact 4:
Input:
gnuplot> set zeroaxis
gnuplot> plot tan(x)
Output:
Fact 5:
Input:
gnuplot> f(x)=x*x
gnuplot> set samples 10
gnuplot> plot f(x)
Output:

Fact 6:
Input:
gnuplot> plot sin(x) lw 3 lc 'red', cos(x) lw 1 lc 'blue'
Output:
Fact 7:
Input:
gnuplot> plot sin(x) lw 2 title ‘The Sinusoid’
Output:

Fact 8:
Input:
gnuplot> $data << EOD
1.57 1.00
7.85 1.00
EOD
gnuplot> set xrange [0:10]
gnuplot> plot sin(x) lw 2, '$data' ps 4
Output:

Fact 9:
Input:
gnuplot> set term win enh 0
gnuplot> test
gnuplot> set term win enh 1
Output:
Exercise 1:
a)
Input:
set xrange [-2*pi:2*pi]
f(x)=x+sin(x)
plot f(x)

Output:

b)
Input:
set yzeroaxis
set xrange [-3:3]
f(x)=x**2+x+1
$intercept<<EOD
0 1
EOD
$minima<<EOD
-0.5 0.75
EOD
plot f(x) title 'Function' ,'$intercept' pt 7, '$minima' pt 5

Output:

c)
Input:
f(x)=x*(x**2-1)
set zeroaxis
$Roots<<EOD
0 0
1 0
-1 0
EOD
$Origin<<EOD
0 0
EOD
plot f(x) lw 2, '$Roots' ps 3, ‘$Origin’ ps 5

Output:

d)
Input:
gnuplot> set zeroaxis
gnuplot> set yrange[-10:10]
gnuplot> set samples 400
gnuplot> set arrow from 1, graph 0 to 1, graph 1 nohead
gnuplot> plot x**2/(x-1) lw 2 lc "pink", x+1 lw 2 lc "magenta"
Output:
e)
Input:
set xrange[0:10]
f(x)=x**2*exp(-x)
g(x)=4*x**2*exp(-2*x)
h(x)=9*x**2*exp(-3*x)
set arrow 1 from 1.99542,0 to 1.99542, 0.543945
set arrow 2 from 1.01389,0 to 1.01389, 0.540579
set arrow 3 from 0.671880,0 to 0.671880, 0.540579
plot f(x) lc 'red', g(x) lc 'green', h(x) lc 'blue'
Output:

Exercise 2
a)
Input:
f(x)=x**3+1-exp(x)
set zeroaxis
set xrange[-8:8]
set yrange[-5:5]
plot f(x)
Output:

b)
Input:
f(x)=3*x**4-6*x**2
set xrange[-5:5]
set yrange[-4:4]
plot f(x)
Output:

c)
Input:
g(x)=5*exp(-0.5*x)
h(x)=x+1
set zeroaxis
set xrange[-10:10]
set yrange[-10:10]
$point<<EOD
1.43927, 2.52348
EOD
plot g(x), h(x) , $point pt 5 title 'Intersection'
Output:

d)
Input:
k(x)=x+3*sin(2*x)
y=4
$intercept<<EOD
3.25830, 4.04488
4.86093, 4.04488
5.92681, 4.04488
EOD
set xrange[-1:8]
plot k(x), y, $intercept pt 7 title 'Intercept'
Output:

e)
Input:
f(x)=exp(-x/100)*cos(x)
set samples 400
set xrange[0:100]
set yrange[-5:5]
plot f(x), y
Output:
Factsheet 2
Fact 1
Input:
gnuplot> plot [0:4] [0:8] 'simple1.txt'
Output:

Fact 2
Input:
gnuplot> plot 'simple1.txt' using 1:2
Output:
Fact 3
Input:
gnuplot>plot ’simple.txt’ index 0 using 1:2 w linespoints

Output:

Fact 4
Input:
plot [0:4] [0:8] ’simple1.txt’ title ’some data’ with lines

Output:
Fact 5
Input:
plot [0:4] [0:8] 'simple1.txt' smooth csplines
Output:

Fact 6
Input:
gnuplot> f(x)=a*exp(-b*x)
gnuplot> a=200
gnuplot> b=1
gnuplot> fit f(x) 'simple1.txt' u 1:2 via a,b
gnuplot> plot 'simple1.txt',f(x)
gnuplot> print a,b
Output:
Exercise 2
a)
Input:
gnuplot> plot 'ex_simple1.txt'
Output:

Input:
gnuplot> plot 'ex_simple1.txt' w linespoints
Output:

b)
Input:
plot 'ex_simple1.txt' with lines
Output:

Input:
plot 'ex_simple1.txt' smooth csplines
Output:

Input:
Output:

Input:
gnuplot> plot 'ex_simple1.txt' smooth sbezier
Output:

c)
Input:
gnuplot> f(x)=a*exp(-x) + b
gnuplot> a=200
gnuplot> b=3
gnuplot> fit f(x) 'sample.txt' via a,b
Output:

Input:
gnuplot> plot 'sample.txt' pt 7, 'sample.txt' w lines, 'sample.txt' smooth csplines, f(x)
Output:
d)
Input:
plot [0:40] [-60:60] 'cavendish_dat.txt' ind 0 u 1:2:3 title 'Graph1' with yerrorbars lw 3,\
'cavendish_dat.txt' ind 1 u 1:2:3 title 'graph2' with yerrorbars lw 3
Output:

Input:
theta(x)=theta0+a*exp(-x/tau)*sin(2*pi*x/T+phi)
fit theta(x) 'cavendish_dat.txt' using 1:2:3 via theta0, a, tau, T, phi
plot 'cavendish_dat.txt', theta(x)

Output:

Input:
theta(x)=theta0+a*exp(-x/tau)*sin(2*pi*x/T+phi)
fit theta(x) 'cavendish_dat.txt' using 1:2:3 via theta0, a, tau, T, phi
plot [0:40] [-60:60] 'cavendish_dat.txt' ind 0 u 1:2:3 title 'Graph1' with yerrorbars lw 3,\
'cavendish_dat.txt' ind 1 u 1:2:3 title 'graph2' with yerrorbars lw 3,\
theta(x) title 'Best-fit curve' lw 3
Output:

You might also like