GNUPLOTはグラフ描画用スクリプト言語です。グラフかきツールは世の中にいっぱいあり、 中にはGNUPLOTよりも「使いやすい」ものもあるでしょうが、私はほとんどGNUPLOTしか使いません。理由は、
3次元プロット
補間・平滑化: set dgrid3d 30,30 set pm3d at b set view 0,0 陰線処理: set hidden3d xyzデータの表示: splot "data.dat 行列データの表示: splot "data.dat matrix
EPSファイルをPNGファイルなどに変換する: ImageMagickのconvertコマンドを使う。ただし、
仕上りが小さすぎて解像度が悪すぎ、みたいな場合は、-densityオプションで調整する。
オプションの位置に注意。参考
例: $ convert -density 144 fig1.eps fig1.png
set xlabel "m^2" ............ 上付き (平方メートル) set xlabel "SO_2" ........... 下付き (二酸化硫黄) set xlabel "{/Symbol m}m" ... ギリシャ文字 (μm) set label "Magnolia" at "2006_0615", 0.2 font "Times-Italic,30" ... イタリック(斜字体)
linetype (lt) (カラーeps)
1: 赤 2: 黄緑 3: 青 4: ピンク 5: 水色 6: 黄色 7: 黒 8: オレンジ 9: 灰色
set linestyleの書式
set style line 番号 lt 色 lw 太さ pt 記号 ps 大きさ
cat <<EOF | gnuplot set terminal postscript enhanced color set size 1.0,0.5 set grid set output "2004_0927_TKY_Betula_FS.eps" set title "2004 0927, Takayama, Betula" set xlabel "wavelength (nm)" set xrange [400:1100] set ylabel "reflectance"; set ytics 0.2; set mytics 0.1; set yrange [0:1] set nokey set style line 1 lt 3 lw 2 pt 0 set style line 2 lt 2 lw 2 pt 0 set style line 3 lt 4 lw 2 pt 0 set style line 4 lt 8 lw 2 pt 0 set y2label "transmittance"; set y2range [0:1] reverse; set y2tics 0.2; set my2tics 0.1 plot "dummy" using 1:2 axes x1y1 ls 1, \ "dummy" using 1:4 axes x1y1 ls 2, \ "dummy" using 1:6 axes x1y1 ls 3, \ "dummy" using 1:8 axes x1y1 ls 4, \ "dummy" using 1:3 axes x1y2 ls 1, \ "dummy" using 1:5 axes x1y2 ls 2, \ "dummy" using 1:7 axes x1y2 ls 3, \ "dummy" using 1:9 axes x1y2 ls 4 EOF set style lineのオプション(線の様式の設定) lt ... 色の指定 1: 赤 2: 黄緑 3: 青 4: ピンク 5: 水色 6: 黄色 7: 黒 8: オレンジ 9: 灰色lw ... 線幅
gnuplot <<EOF set terminal postscript enhanced set output "2005_TKY_leaf_SPAD.eps" set size 1.0,0.6 set xdata time; set timefmt "%Y_%m%d"; set format x "%m/%d" set xrange ['2005_0501':'2005_1210'] set xlabel "month/day (2005)" set ylabel "SPAD" set style line 1 lt 1 lw 1 pt 0 set style line 2 lt 1 lw 1 pt 1 set style line 3 lt 2 lw 2 pt 4 set style line 4 lt 4 lw 3 pt 7 plot "2005_TKY_shoot_SPAD__stat_Be.txt" u 1:2:5 notitle w errorbar ls 1, "2005_TKY_shoot_SPAD__stat_Be.txt" u 1:2 t "Betula" w lp linestyle 2, \ "2005_TKY_shoot_SPAD__stat_Qc.txt" u 1:2:5 notitle w errorbar ls 1, "2005_TKY_shoot_SPAD__stat_Qc.txt" u 1:2 t "Quercus" w lp linestyle 3, \ "2005_TKY_shoot_SPAD__stat_other.txt" u 1:2:5 notitle w errorbar ls 1, "2005_TKY_shoot_SPAD__stat_other.txt" u 1:2 t "others" w lp linestyle 4 EOF convert -density 72 2005_TKY_leaf_SPAD.eps -rotate 90 2005_TKY_leaf_SPAD.png
gnuplot <<EOF set terminal postscript eps enhanced color set output "TKY_Terra_VI.eps" set size 0.8,0.4; set lmargin 10 set title "Takayama, Terra/MODIS" set xdata time; set timefmt "%Y_%j" set xlabel "month (2003-2004)"; set format x "%m"; set xrange ['2003_274':'2004_273'] set ylabel "NDVI"; set yrange [0.0:0.9]; set ytic 0,0.2 set grid set key right bottom plot "Terra_nocloud_NDVI.txt" using 1:2 title "Terra MOD09" with line 1, \ "TKY_MOD_L1B.txt" using 1:4 title "Terra L1B" with line 3 EOF convert -density 144 TKY_Terra_VI.eps TKY_Terra_VI.png
注: eps2pngで出力を大きくしたいときは、eps2png -scale 2 hogehoge.epsのようにする。
注: eps2pngでは、カラーepsがモノクロに変換されてしまう。カラーでpngにしたいときは、GIMPでキャプチャーするか。
####### SPOTveg ######## awk '$1>1900 && $4$lt;=1.0 {print $0}' Takayama_SPOTveg.txt>dummy gnuplot<<EOF set term postscript eps enhanced set output "1999_2001_Takayama_SPOTveg.eps" set size 1.0,0.4 set key left top set title "SPOT/Vegetation" set xlabel "month (year 1999-2001)" set ylabel "NDVI, reflectance" set xdata time set timefmt "%Y/%j" set xrange ["1999/1":"2001/365"] set timefmt "%y/%m" set xtics ("99/1", "99/3", "99/5", "99/7", "99/9", "99/11",\ "00/1", "00/3", "00/5", "00/7", "00/9", "00/11",\ "01/1", "01/3", "01/5", "01/7", "01/9", "01/11") set ytics 0.2 set format x "%m" set timefmt "%Y %j" plot "dummy" using 1:5 title "red" w lp 1, \ "dummy" using 1:6 title "NIR" w lp 2, \ "dummy" using 1:3 title "NDVI" w l 1 EOF rm dummy
set term postscript enhanced set output "TKY_FPAR_MODIS.eps" set size 1.0,0.6 set lmargin 10 set title "Fraction of Absorbed PAR (FPAR), Takayama set xdata time set timefmt "%Y_%j" set xlabel "2003" set format x "%m/%d" set key left bottom set yrange [0:1] set ylabel "FPAR" set xrange ['2003_274':'2003_330'] plot "TKY_Terra_FPAR.txt" using 1:2 title "satellite: Terra MODIS" w l, \ "TKY_Aqua__FPAR.txt" using 1:2 title "satellite: Aqua MODIS " w l
gnuplot << EOF set size 0.5,1.0 set terminal postscript enhanced color set output "site_lat_alt.eps" set yrange [34:37.5] set xlabel "altitude [m]" set ylabel "latitude [degree]" set key bottom set style line 1 lt 3 pt 9 ps 0.9 set style line 2 lt 8 pt 7 ps 1.0 set style line 3 lt 4 pt 7 ps 1.5 plot "site_lat_alt_univ.txt" u 3:2 title "University observatories" w p linestyle 3, \ "site_lat_alt_rain.txt" u 3:2 title "JMA: rain only" w p linestyle 1, \ "site_lat_alt.txt" u 3:2 title "JMA: rain and temperature" w p linestyle 2 EOF
gnuplot << EOF set output "PEN_review_Fig3G.eps" set terminal postscript eps enhanced color 26 set size 0.9,0.7 set logscale set mxtics 10 set mytics 10 set format y "10^{%L}" set format x "10^{%L}" set xrange [1E-6:3E-3] set style line 1 lt 1 lw 3 ps 1.5 pt 6 set style line 2 lt 3 lw 2 ps 1.5 pt 7 set xlabel "Radius (cm)" set ylabel "dV/dlnr (cm^3/cm^2)" set key right bottom plot "05110100.vol.good.ave" u 1:2 w lp ls 1 t "2005/11/01 TGF", "06041800.vol.good.ave" u 1:2 w lp ls 2 t "2006/04/18 TGF" EOF
P(n,x)=(n==0)?1:((n==1)?x:((2*n-1)*x*P(n-1,x)-(n-1)*P(n-2,x))/n) plot P(0,x),P(1,x),P(2,x),P(3,x),P(4,x),P(5,x)↑3項間漸化式で定義できる!
チェビシェフ多項式
T(n,x)=(n==0)?1:((n==1)?x:2*x*T(n-1,x)-T(n-2,x)) set samples 1000 plot T(0,x),T(1,x),T(2,x),T(15,x)