P05 | Visualisasi Data dengan gnuplot
Modul Praktikum FI2283 Pemrograman dan Simulasi Fisika
Versi 2013.09.29
Catatan. Dalam praktikum ini akan dipelajari dan dipraktekkan bagaimanamembuat visualisasi data dengan memanfaatkan aplikasi gnuplot. Visualisasiyang dimaksud dalam hal ini masih dibatasi dalam bentuk grafik y terhadap x,di mana variabel x dan y dapat berarti data apa saja.
1 Grafik y terhadap x 49
2 Grafik dari dua berkas berbeda 51
3 Grafik dari berkas dengan banyak kolom data 53
4 Grafik sebagian data 55
5 Grafik sebagian data (lagi) 60
6 Grafik dari fungsi 61
7 Grafik dari fungsi dan berkas data 64
8 Fitting data dengan suatu fungsi 67
9 Fitting data dengan suatu fungsi (lagi) 71
10 Animasi sederhana dengan gnuplot dan convert 71
1 Grafik y terhadap x
Buat berkas suatu berkas teks, dengan penyunting teks yang Anda kuasai, yangisinya adalah sebagai berikut ini
49
#x y
0 12
1 5
2 0
3 -3
4 -4
5 -3
6 0
7 5
8 12
9 21
10 32
dan simpan dengan nama data-01.txt. Kemudian buat berkas teks lain yangberisi script untuk gnuplot
# plot-01.gps
# Plot data and produce EPS file
# Sparisoma Viridi
# 20130929.0921
# Execute: gnuplot plot-01.gps
# Set terminal to eps
set term post eps color enhanced
# Set output file
set output "data-01.eps"
# Set input file
input="data-01.txt"
# Set image size
set size 0.9, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 24"
set xtics 2 font "Times, 22"
set xrange [0:10]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 24"
set ytics 10 font "Times, 22"
50
-10
0
10
20
30
40
0 2 4 6 8 10
y (
m)
x (m)
Gambar 1: Hasil eksekusi script plot-01.gps yang dipanggil dengan gnuplot.
set yrange [-10:40]
# Set grid
set grid xtics ytics
# Plot data
plot input u 1:2 title "" pt 4 ps 2.5
dan simpan dengan nama plot-01.gps.
Tugas 1. Jalankan gnuplot untuk mengeksekusi berkas teks plot-01.gpsdengan cara
gnuplot plot-01.gps
sehingga menghasilkan berkas gambar data-01.eps sebagaimana diberikan dalamGambar 1. Modifikasi script gnuplot sebelumnya sehingga dapat menghasilkanGambar 2. Simpan hasil modifikasi script tersebut dengan nama plot-01a.gps.Jelaskan perbedaan hasil keluaran kedua script tersebut dalam berkas laporan.txt.
2 Grafik dari dua berkas berbeda
Buat berkas suatu berkas teks, dengan penyunting teks yang Anda kuasai, yangisinya adalah sebagai berikut ini
#x y
51
-10
0
10
20
30
40
0 2 4 6 8 10
y (
m)
x (m)
Gambar 2: Hasil eksekusi script plot-01a.gps yang dipanggil dengan gnuplot.
0 -38.4
1 -21
2 -9.6
3 -3
4 0
5 0.6
6 0
7 -0.6
8 0
9 3
10 9.6
dan simpan dengan nama data-02.txt. Kemudian buat berkas teks lain yangberisi script untuk gnuplot
# plot-02.gps
# Plot data and produce EPS file
# Sparisoma Viridi
# 20130929.1011
# Execute: gnuplot plot-02.gps
# Set terminal to eps
set term post eps color enhanced
# Set output file
set output "data-02.eps"
52
# Set input file
input1="data-01.txt"
input2="data-02.txt"
# Set image size
set size 0.9, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 24"
set xtics 2 font "Times, 22"
set xrange [0:10]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 24"
set ytics 10 font "Times, 22"
set yrange [-10:40]
# Set grid
set grid xtics ytics
# Plot data
plot \
input1 u 1:2 w lp title "" pt 4 ps 2.5, \
input2 u 1:2 w lp title "" pt 6 ps 2.5
dan simpan dengan nama plot-02.gps.
Tugas 2. Jalankan gnuplot untuk mengeksekusi berkas teks plot-02.gps den-gan cara yang sama seperti sebelumnya sehingga menghasilkan berkas gambardata-02.eps sebagaimana diberikan dalam Gambar 3. Jelaskan apa perbedaantujuan dari script ini dibandingkan dengan script sebelumnya, tuliskan dalamlaporan.txt.
3 Grafik dari berkas dengan banyak kolom data
Buatlah berkas teks yang berisikan
#x y1 y2 y3
0 5 12 -38.4
1 8 5 -21
53
-10
0
10
20
30
40
0 2 4 6 8 10
y (
m)
x (m)
Gambar 3: Hasil eksekusi script plot-02.gps yang dipanggil dengan gnuplot.
2 11 0 -9.6
3 14 -3 -3
4 17 -4 0
5 20 -3 0.6
6 23 0 0
7 26 5 -0.6
8 29 12 0
9 32 21 3
10 35 32 9.6
dan simpan dengan nama data-03.txt. Dalam gnuplot, saat memanggil per-intah plot, dapat dipilih pasangan kolom data mana yang ingin ditampilkan.Untuk kolom C1 dan C2 gunakan
.. u C1:C2 ..
Tugas 3. Modifikasi script sebelumnya sehingga dapat diperoleh Gambar 4.Simpan script tersebut dengan nama plot-03.gps dengan hasil keluarannyaadalah data-03.eps.
Gunakan potongan script berikut apabila diperlukan
# Plot data
plot \
input u 1:2 w lp pt 4 ps 2.5 \
title "3{/Italic x} + 5", \
54
-10
0
10
20
30
40
0 2 4 6 8 10
y (
m)
x (m)
3x + 5
(x -2 )(x - 6)
0.2(x-4)(x-6)(x-8)
Gambar 4: Isi dari berkas data-03.eps, yang merupakan hasil eksekusi scriptplot-03.gps.
input u 1:3 w lp pt 6 ps 2.5 \
title "({/Italic x} -2 )({/Italic x} - 6)", \
input u 1:4 w lp pt 8 ps 2.5 \
title "0.2({/Italic x}-4)({/Italic x}-6)({/Italic x}-8)"
4 Grafik sebagian data
Ketik dan kompilasi program berikut ini untuk menghasilkan berkas data-04.txt
/*
gen-data.cpp
20130929.1126
Sparisoma Viridi
Generate data for gnuplot
Compile: g++ gen-data.cpp -o gen-data
Execute: ./gen-data
*/
#include
#include
#include
const double PI = 3.141529;
using namespace std;
55
int main(int argc, char *argv[]) {
// Set ouput filename
char ofn[] = "data-04.txt";
ofstream fout;
fout.open(ofn);
if(fout.is_open()) {
// Oscillation parameters
double f1 = 10.0;
double f2 = 20.0;
double fi1 = 0.0;
double fi2 = 0.0;
double A1 = 1.0;
double A2 = 1.5;
// Iteration parameters
double t0 = 0.0;
double t1 = t0 + 3.0 / f1;
double t2 = t1 + 4.0 / f2;
double t = 0.0;
double dt = 1.0E-4;
// Do interation
fout
return 0;
}
dengan mengikuti petunjuk dalam kode tersebut. Kemudian buat script untukgnulplot berikut ini
# plot-04.gps
# Plot data and produce EPS file
# Sparisoma Viridi
# 20130929.1214
# Execute: gnuplot plot-04.gps
# Set terminal to eps
set term post eps color enhanced font "Times, 32"
# Set input file
input="data-04.txt"
# Set image size
set size 0.9, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic t} (s)" font "Times, 32"
set xtics 0.1 font "Times, 30"
set xrange [0:0.5]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 32"
set ytics 0.5 font "Times, 30"
set yrange [-1.5:1.5]
# Set grid
set grid xtics ytics
# Set legend
set key inside left top spacing 4
# All data
# Set output file
set output "data-04.eps"
57
# Plot data
plot \
input u 1:2 w lp pt 4 ps 1.5 \
title ""
# Every 10 data
# Set output file
set output "data-04a.eps"
# Plot data
plot \
input u 1:2 every 10 w lp pt 4 ps 1.5 \
title ""
# Every 20 data
# Set output file
set output "data-04b.eps"
# Plot data
plot \
input u 1:2 every 20 w lp pt 4 ps 1.5 \
title ""
# Every 20 data
# Set output file
set output "data-04c.eps"
# Plot data
plot \
input u 1:2 every 50 w lp pt 4 ps 1.5 \
title ""
dan simpan dalam berkas teks dengan nama plot-04.gps. Jalankan dengangnuplot sehingga menghasilkan berkas-berkas data-04.eps, data-04a.eps,data-04b.eps, dan data-04c.eps, sebagaimana ditampilkan dalam Gambar5.
Tugas 4. Jelaskan dalam berkas laporan.txt apa fungsi dari opsi every dalampenggunaan perintah plot dalam gnuplot.
58
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
(a) (b)
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
(c) (d)
Gambar 5: Hasil eksekusi script plot-04.gps untuk berkas data-04.txt untuksetiap: (a) 1 data, (b) 10 data, (c) 20 data, dan (d) 50 data.
59
5 Grafik sebagian data (lagi)
Kadang tidak semua data ingin ditampilkan tetapi hanya 3000 data pertamadari 5000 data, yang misalnya terdapat dalam berkas data-04.txt. Atau 2000data terakhirnya saja. Untuk memahaminya, perhatikan contoh script berikutini
# plot-05.gps
# Plot data and produce EPS file
# Sparisoma Viridi
# 20130929.1538
# Execute: gnuplot plot-05.gps
# Set terminal to eps
set term post eps color enhanced font "Times, 32"
# Set input file
input="data-04.txt"
# Set image size
set size 0.9, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic t} (s)" font "Times, 32"
set xtics 0.1 font "Times, 30"
set xrange [0:0.5]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 32"
set ytics 0.5 font "Times, 30"
set yrange [-1.5:1.5]
# Set grid
set grid xtics ytics
# Set legend
set key inside left top spacing 4
# All data
# Set output file
set output "data-05.eps"
60
# Plot data
plot \
input u 1:2 w lp pt 4 ps 1.5 \
title ""
# First 3000 data of 5000 data
# Set output file
set output "data-05a.eps"
# Plot data
plot \
input u 1:2 every ::0::3000 w lp pt 4 ps 1.5 \
title ""
# Last 2000 data of 5000 data
# Set output file
set output "data-05b.eps"
# Plot data
plot \
input u 1:2 every ::3000::5000 w lp pt 4 ps 1.5 \
title ""
dan simpan dengan nama plot-05.gps. Jalankan sehingga dihasilkan grafik-grafik seperti dalam Gambar 6.
Tugas 5. Modifikasi script plot-05.gps sehingga grafik dalam Gambar 6.b dan6.b memberikan rentang sumbu horizontal (atau sumbu t) yang tidak kosongsebagian. Jadi untuk Gambar 6.b digambarkan 0 s t 0.3 s dan untukGambar 6.b digambarkan 0.3 s t 0.5 s. Simpan kedua gambar dengannama data-05a.eps dan data-05b.eps.
6 Grafik dari fungsi
Bagaimana menggambarkan data dari suatu berkas teks menggunakan gnuplottelah dipelajari pada praktikum ini dalam tugas-tugas sebelum bagian ini. Berikut-nya akan dipelajari bagaimana menggambarkan suatu fungsi. Untuk itu salinscript berikut ini
# plot-06.gps
# Plot data and produce EPS file
61
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
(a)
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
(b)
-1.5
-1
-0.5
0
0.5
1
1.5
0 0.1 0.2 0.3 0.4 0.5
y (
m)
t (s)
(c)
Gambar 6: Hasil eksekusi script plot-05.gps untuk berkas data-04.txt untuk:(a) seluruh 5000 data, (b) 3000 data pertama, dan (c) 2000 data terakhir.
62
# Sparisoma Viridi
# 20130929.1608
# Execute: gnuplot plot-06.gps
# Set terminal to eps
set term post eps color enhanced font "Times, 24"
# Set image size
set size 0.9, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 4 font "Times, 28"
set mxtics 2
set xrange [0:20]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 30"
set ytics 1000 font "Times, 28"
set mytics 2
set yrange [-2000:2500]
set format y "%.0t {/Arial x} 10^{%T}"
# Set grid
set grid xtics ytics mxtics mytics
# Set legend
set key top spacing 4
# Set output file
set output "data-06.eps"
# Define a function of a pre-defined dummy variabel x
f(x) = (x-1)*(x-8)*(x-15)*(x-18)
# Plot data
plot f(x) w l lw 6\
title "{/Italics y} = \
({/Italic x} - 1)\
({/Italic x} - 8)\
({/Italic x} - 15)\
({/Italic x} - 18)"
63
-2 x 103
-1 x 103
0 x 100
1 x 103
2 x 103
0 4 8 12 16 20
y (
m)
x (m)
y = (x - 1)(x - 8)(x - 15)(x - 18)
Gambar 7: Hasil eksekusi script plot-06.gps yang menggambarkan fungsi y =(x 1)(x 8)(x 15)(x 18).
dengan nama plot-06.gps dan jalankan sehingga diperoleh Gambar 7.
Tugas 6. Modifikasi script plot-06.gps menjadi plot-06a.gps sehingga dapatmenggambarkan fungsi
y = 2x2 5x + 1.373, (1)
untuk rentang x [2.5, 7.5] sebagaimana digambarkan dalam Gambar 8,dalam bentuk berkas data-06a.gps.
7 Grafik dari fungsi dan berkas data
Salin data berikut ini
#x y
0 2.8
1 5.2
2 7
3 9.3
4 10.5
5 13.5
6 15.3
7 16.9
8 18.7
9 20.6
64
-2 x 101
0 x 100
2 x 101
4 x 101
6 x 101
8 x 101
-2 0 2 4 6
y (
m)
x (m)
y = 2x2 - 5x + 1.373
Gambar 8: Plot Persamaan (1) untuk rentang x [2.5, 7.5].
10 23.4
dalam berkas teks dengan nama data-07.txt dan juga script berikut ini
# plot-07.gps
# Plot data and produce EPS file
# Sparisoma Viridi
# 20130929.1741
# Execute: gnuplot plot-07.gps
# Set terminal to eps
set term post eps color enhanced font "Times, 24"
# Set image size
set size 0.8, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 2 font "Times, 28"
set mxtics 2
set xrange [0:10]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 30"
65
0
5
10
15
20
25
0 2 4 6 8 10
y (
m)
x (m)
y = 2x + 3
Eksperimen
Gambar 9: Plot Persamaan y = 2x + 3 dan data dari berkas data-07.txtmenggunakan script plot-07.gps.
set ytics 5 font "Times, 28"
set mytics 2
set yrange [0:25]
# Set grid
set grid xtics ytics
# Set legend
set key top left spacing 4
# Set output file
set output "data-07.eps"
# Define a function of a pre-defined dummy variabel x
f(x) = 2*x + 3
# Plot data
plot \
f(x) w l lw 6 title "{/Italics y} = 2{/Italic x} + 3", \
"data-07.txt" u 1:2 w p pt 5 ps 2.5 t "Eksperimen"
dalam berkas dengan nama plot-07.gps. Jalankan script sehingga diperolehberkas data-07.eps seperti dalam Gambar 9.
66
Tugas 7. Buat data Anda sendiri dalam berkas teks data-07a.txt dan mod-ifikasi script plot-07.gps menjadi plot-07a.gps sehingga dapat menggam-barkan fungsi dan data yang Anda buat.
8 Fitting data dengan suatu fungsi
Gnuplot memiliki perintah fit yang dapat digunakan untuk fitting data ter-hadap suatu fungsi yang diinginkan. Untuk pembelajaran ini akan digunakandata dalam berkas teks data-07.txt sebelumnya. Salin script berikut ini
# plot-08.gps
# Plot data, fit witn equation and produce EPS file
# Sparisoma Viridi
# 20130929.1824
# Execute: gnuplot plot-08.gps
# Set terminal to eps
set term post eps color enhanced font "Times, 24"
# Set image size
set size 0.8, 1.0
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 2 font "Times, 28"
set mxtics 2
set xrange [0:10]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 30"
set ytics 5 font "Times, 28"
set mytics 2
set yrange [0:25]
# Set grid
set grid xtics ytics
# Set legend
set key right bottom spacing 4
# Set input file
67
input = "data-07.txt"
# Set output file
set output "data-08.eps"
# Define a function of a pre-defined dummy variabel x
f(x) = a*x + b
# Fit the function to data
fit f(x) input via a, b
# Title for equation
eqnt = sprintf("{/Italics y} = %f{/Italics y} + %f", a, b);
# Plot data
plot \
f(x) w l lw 6 title eqnt, \
input u 1:2 w p pt 5 ps 2.5 t "Eksperimen"
dalam berkas dengan nama plot-08.gps. Jalankan script sehingga diperolehberkas data-08.eps seperti dalam Gambar 10. Proses iterasi untuk menemukannilai a dan b dalam fungsi yang digunakan, yaitu
f(x) = ax + b (2)
adalah seperti berikut ini
Iteration 0
WSSR : 652.38 delta(WSSR)/WSSR : 0
delta(WSSR) : 0 limit for stopping : 1e-05
lambda : 4.24264
initial set of free parameter values
a = 1
b = 1
/
Iteration 1
WSSR : 10.2475 delta(WSSR)/WSSR : -62.6622
delta(WSSR) : -642.132 limit for stopping : 1e-05
lambda : 0.424264
resultant parameter values
68
0
5
10
15
20
25
0 2 4 6 8 10
y (
m)
x (m)
y = 1.997273x + 3.031818
Eksperimen
Gambar 10: Plot Persamaan (2) hasil perintah fit dan data dari berkasdata-07.txt menggunakan script plot-08.gps.
a = 2.1694
b = 1.44425
/
Iteration 2
WSSR : 1.19946 delta(WSSR)/WSSR : -7.54342
delta(WSSR) : -9.04806 limit for stopping : 1e-05
lambda : 0.0424264
resultant parameter values
a = 2.00981
b = 2.94458
/
Iteration 3
WSSR : 1.17555 delta(WSSR)/WSSR : -0.0203467
delta(WSSR) : -0.0239185 limit for stopping : 1e-05
lambda : 0.00424264
resultant parameter values
a = 1.99728
69
b = 3.03177
/
Iteration 4
WSSR : 1.17555 delta(WSSR)/WSSR : -6.9433e-09
delta(WSSR) : -8.16217e-09 limit for stopping : 1e-05
lambda : 0.000424264
resultant parameter values
a = 1.99727
b = 3.03182
After 4 iterations the fit converged.
final sum of squares of residuals : 1.17555
rel. change during last iteration : -6.9433e-09
degrees of freedom (FIT_NDF) : 9
rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.361409
variance of residuals (reduced chisquare) = WSSR/ndf : 0.130616
Final set of parameters Asymptotic Standard Error
======================= ==========================
a = 1.99727 +/- 0.03446 (1.725%)
b = 3.03182 +/- 0.2039 (6.724%)
correlation matrix of the fit parameters:
a b
a 1.000
b -0.845 1.000
Tugas 8. Jelaskan apa maksud bagian
# Title for equation
eqnt = sprintf("{/Italics y} = %f{/Italics y} + %f", a, b);
dalam script plot-08.gps? Jelaskan jawaban Anda dalam berkas laporan.txt.
70
-5
0
5
10
15
20
25
0 2 4 6 8 10
y (
m)
x (m)
y = -0.002681x2 + 2.024079x + 2.991608
Eksperimen
Gambar 11: Plot Persamaan (3) hasil perintah fit dan data dari berkasdata-07.txt menggunakan script plot-09.gps.
9 Fitting data dengan suatu fungsi (lagi)
Tugas 9. Modifikasi script plot-08.gps menjadi plot-09.gps sehingga dapatmengakomodasi model atau fungsi berbentuk
f(x) = ax2 + bx + c (3)
untuk data yang sama dalam berkas teks data-07.txt. Laporkan nilai-nilaia, b, dan c dalam berkas laporan.txt dan tampilkan grafiknya seperti dalamGambar 11.
10 Animasi sederhana dengan gnuplot dan convert
Salin script berikut ini
# plot-10.gps
# Plot data, fit witn equation and produce EPS file
# Sparisoma Viridi
# 20130929.2003
# Execute: gnuplot plot-10.gps
# Set terminal to eps
71
set term post eps color enhanced font "Times, 24"
# Set image size
set size 1.2, 0.8
# Set bottom margin -- for some distro it needs correction
set bmargin 3.5
# Set x-axis
set xlabel "{/Italic x} (m)" font "Times, 30"
set xtics 0.5 font "Times, 28"
set mxtics 4
set xrange [0:2]
# Set y-axis
set ylabel "{/Italic y} (m)" font "Times, 30"
set ytics 0.1 font "Times, 28"
set mytics 2
set yrange [-0.2:0.2]
# Set grid
set grid xtics ytics mxtics mytics
# Define a wave function
PI = 3.141529
A = 0.2
l = 1.0
f = 10.0
T = 1.0 / f
k = 2.0 * PI / l
w = 2.0 * PI / T
y(x, t) = A * sin(k*x - w*t)
# Plot data
a = 0.0
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.1
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
72
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.2
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.3
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.4
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.5
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.6
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
73
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.7
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.8
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
a = 0.9
t = a * T
timestamp = sprintf("{/Italics t} = %1.2f T", a);
filename = sprintf("data-10-%1.1f.eps", a);
set output filename
unset label
set label timestamp at -0.25, -0.28 font ", 28"
plot y(x, t) w l lw 8 t ""
dalam berkas teks plot-10.gps dan jalankan sehingga diperoleh berkas-berkasdata-10-0.0.eps sampai data-10-0.9.eps. Konversi berkas-berkas .eps yangdihasilkan menjadi .png dengan cara menggunakan perintah berikut pada kon-sol
convert data-10-0.0.eps data-10-0.0.jpg
convert data-10-0.1.eps data-10-0.1.jpg
convert data-10-0.2.eps data-10-0.2.jpg
convert data-10-0.3.eps data-10-0.3.jpg
convert data-10-0.4.eps data-10-0.4.jpg
convert data-10-0.5.eps data-10-0.5.jpg
convert data-10-0.6.eps data-10-0.6.jpg
convert data-10-0.7.eps data-10-0.7.jpg
convert data-10-0.8.eps data-10-0.8.jpg
74
convert data-10-0.9.eps data-10-0.9.jpg
convert *.jpg data-10.gif
Tugas 10. Lihat hasil konversi dari berkas *.jpg menjadi data-10.gif meng-gunakan penjelajah internet yang ada. Laporkan hasil pengamatan Anda dalamberkas laporan.txt. Ilustrasi snapshot grafik fungsi gelombang dapat dilihatdalam Gambar 12.
Keluaran praktikum
1. data-01.txt, plot-01.gps, data-01.eps, plot-01a.gps, data-01a.eps,data-02.txt, plot-02.gps, data-02.eps, data-03.txt, plot-03.gps,data-03.eps, data-gen.cpp, data-04.txt, data-04.eps, data-04a.eps,data-04b.eps, data-04c.eps, plot-05.gps, data-05a.eps, data-05b.eps,plot-06.gps, data-06.eps, plot-06a.gps, data-06a.eps, data-07.txt,plot-07.gps, data-07.eps, data-07a.txt, plot-07a.gps, data-07a.eps,plot-08.gps, data-08.eps, plot-09.gps, data-09.eps dan .
2. laporan.txt yang berisikan jawaban dari Tugas 1, 2, 4, 6, 8, 9, dan 10.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0Unported License. 1
1Sparisoma Viridi , .., 2013
75
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.00 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.10 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.20 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.30 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.40 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.50 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.60 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.70 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.80 T
-0.2
-0.1
0
0.1
0.2
0 0.5 1 1.5 2
y (
m)
x (m)t = 0.90 T
Gambar 12: Hasil yang diperoleh dari script plot-10.gps untuk waktu-waktu:0.0T , 0.1T , 0.2T , 0.3T , 0.4T , 0.5T , 0.6T , 0.7T , 0.8T , dan 0.9 T , di mana Tadalah periode osilasi.
76
Grafik y terhadap xGrafik dari dua berkas berbedaGrafik dari berkas dengan banyak kolom dataGrafik sebagian dataGrafik sebagian data (lagi)Grafik dari fungsiGrafik dari fungsi dan berkas dataFitting data dengan suatu fungsiFitting data dengan suatu fungsi (lagi)Animasi sederhana dengan gnuplot dan convert
Top Related