実験データ等をgnuplotを用いて,グラフにして表現したい場合には,以下のような手順で行います.
今回作成するグラフは以下のようなグラフです.
粒度試験結果(以下の例では"PSD")
突き固めによる土の締固め試験結果(以下の例では"Sc)
以下のようなデータがあったとします(テキストファイルで保存).
<PSD.txt>
2.0000
100.0
0.8500
91.8
0.4250
75.4
0.2500
62.9
0.1060
45.2
0.0750
43.4
0.0493
39.0
0.0355
34.5
0.0229
29.0
0.0137
20.9
0.0098
16.3
0.0070
12.7
0.0036
8.2
0.0015
7.3
2.0000
100.0
0.8500
91.6
0.4250
75.1
0.2500
61.8
0.1060
44.2
0.0750
42.5
0.0498
37.4
0.0357
33.6
0.0232
27.1
0.0136
21.5
0.0098
16.8
0.0070
13.1
0.0035
10.3
0.0015
8.4
2.0000
100.0
0.8500
92.2
0.4250
75.1
0.2500
61.9
0.1060
44.3
0.0750
42.6
0.0510
38.7
0.0365
34.9
0.0235
29.3
0.0140
19.8
0.0100
16.0
0.0071
14.2
0.0036
10.4
0.0015
9.4
<Sc.txt>
# Test for soil compaction using a rammer
#measuring points
# w
rho_d
5.7
1.836
8.2
1.888
10.1
1.913
11.4
1.911
13.4
1.885
15
1.846
15.9
1.819
17.5
1.776
<Sc2.txt>
0.0 2.698
5.0 2.377
10.0 2.125
15.0 1.921
20.0 1.752
25.0 1.611
30.0 1.491
35.0 1.388
40.0 1.298
45.0 1.219
50.0 1.149
55.0 1.066
60.0 1.030
65.0 0.980
70.0 0.934
75.0 0.892
80.0 0.854
85.0 0.819
90.0 0.787
95.0 0.757
100.0 0.730
105.0 0.704
110.0 0.680
115.0 0.658
120.0 0.637
125.0 0.617
130.0 0.599
135.0 0.581
140.0 0.565
145.0 0.549
150.0 0.535
155.0 0.521
160.0 0.507
165.0 0.495
170.0 0.483
175.0 0.472
180.0 0.461
185.0 0.450
190.0 0.440
195.0 0.431
200.0 0.422
このデータをグラフにするには,対話形式で作成しても良いのですが,バッチ処理を行う方が簡単であると同時に,複数のデータを処理する際に便利です.
以下にバッチ処理を行うためのコマンドファイルを作成します.
<PSD.gp>
# Test for Particle Size Distribution of Soils
#
set logscale x 10
set xrange [0.001:10]
set tics font "Times New Roman,18"
set xtics 10
set yrange [0.0:100.0]
set ytics 10
set mytics 10
set xlabel font "Times New Roman,18"
set xlabel "{Grain Size (mm)}"
set ylabel font "Times New Roman,18"
set ylabel "{Percentage Passing (%)}"
set size square
set key font "Times New Roman,18"
set key right bottom
set key box
plot "./PSD.txt" using 1:2 with points pointtype 7 title"grain size accumulation curve",\
"" smooth cspline with lines notitle
pause -1 "press [Enter] key or [OK] button to quit"
<Sc.gp>
# Test for Particle Size Distribution of Soils
#
set xrange [5:20]
set tics font "Times New Roman,18"
set xtics 5
set mxtics 8
set yrange [1.7:2.0]
set ytics 0.1
set mytics 10
set xlabel font "Times New Roman,18"
set xlabel "{water content w(%)}"
set ylabel font "Times New Roman,18"
set ylabel "{dry dendensity {/Symbol r}_d (g/cm^{3})}"
set size square
set key font "Times New Roman,18"
set key right bottom
set key box
plot "./SC.txt" using 1:2 with points pointtype 7 title "dry density - water content curve",\
"" smooth cspline with lines notitle
replot "./SC2.txt" using 1:2 with points pointtype 7 title "zero air voids curve",\
"" smooth cspline with lines notitle
pause -1 "press [Enter] key or [OK] button to quit"
これらのコマンドファイル(.gp)をターミナルから以下のように実行すると,先に示したグラフを描くことができます.
$ gnuplot
G N U P L O T
Version 5.0 patchlevel 1 last modified 2015-06-07
Copyright (C) 1986-1993, 1998, 2004, 2007-2015
Thomas Williams, Colin Kelley and many others
gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help FAQ"
immediate help: type "help" (plot window: hit 'h')
Terminal type set to 'aqua'
gnuplot> load 'PSD.gp'
press [Enter] key or [OK] button to quit
gnuplot> load 'SC.gp'
press [Enter] key or [OK] button to quit
gnuplot> q
なお,コマンドファイルを実行する際には,コマンドファイル(.gp)とデータファイル(.txt)を同じディレクトリに保存しておく必要があります.