binaries included: * wgnuplot.exe: The default executable * wgnuplot_pipes.exe: plot `<awk -f change.awk data.dat' * pgnuplot.exe: accept commands on stdin and pipe them to an wgnuplot text winodw. (注)角藤版では、wgnuplot_pipes.exeが含まれていない。 Gnuplot 4.3 patch level 0 の Windows 用バイナリです
gnuplot> cd 'd:\home' : cd to d:\home (注)single quoteを用いること gnuplot> pwd : print working diretory
epsへの出力 plot ...; set term[inal] pos[tscript] eps enhanced; set output 'data.eps'; rep; # epsファイル名を設定。epsに。 set term windows; set output # 元に戻す
p[lot] : 2-d functions and data splot : 3-d surfaces and data rep[lot] : repeat the last plot or splot
plot {[range]} {[function] | {'[datafile]' {datafile-modifiers}}} {axes [axes] } { [title-spec] } {with [style]} {, {definitions, } [function] ...} -> help plot, help plot with, help plot using, help plot smooth
gnuplot> plot sin(x) title 'Sine Function', tan(x) title 'Tangent' gnuplot> splot sin(x*y/20)
------force.dat------------ # This file is called force.dat # Force-Deflectin data for a beam and a bar # Deflection Col-Force Beam-Force 0.000 0 0 0.001 104 51 0.002 202 101 0.003 298 148 0.0031 290 149 0.004 289 201 0.0041 291 209 0.005 310 250 0.010 311 260 0.020 280 240 (注)column間はtab,spaceのみ gnuplot> plot 'force.dat' using 1:2 title 'Column', \ '' using 1:3 title 'Beam' (注)継続行は \ ''は前と同じファイルを示す help plot datafile
styles : lines, points,dots,histgrams and so on --> help style gnuplot> plot 'force.dat' using 1:2 title 'Column' with lines, \ '' u 1:3 t 'Beam' w linepoints
set title "Force-Deflection Data" set xlabel "Deflection (meters)" set ylabal "Force (kN)" set xrange [0.001:0.005] set yrange [20:500] set autoscale set key 0.01, 100 unset key set label "yield point" at 0.003, 260 unset label set logscale (x,xy,z) # (x軸、xy軸、z軸) unset logscale; set logscale set xtics (0.002,0.004,0.006,0.008) unset xtics; set xtics auto その他のset arrow, border, clip, contour, grid, mapping, polar, surface, time, view...
-------force.p---------------------- # Gnuplot script file for plotting data in file "force.dat" # This file is called force.p 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] plot "force.dat" using 1:2 title 'Column' with linespoints , \ "force.dat" using 1:3 title 'Beam' with points -------------------------------------------------- スクリプトの実行 gnuplot> load 'force.p' スクリプトの保存 gnuplot> save 'xxxx.plt'
set datafile commentschars "#%"
f1(x) = a1*tanh(x/b1) a1 = 300;b1=0.005; # initial guess fit f1(x) 'force.dat' u 1:2 via a1,b1 f2(x)=a2*tanh(x/b2) a2=300;b2=0.005; fit f2(x) 'force.dat' u 1:3 via a2,b2 # set key 0.018,150 title "F(x) = A tanh (x/B)" -->受け付けない。 set title 'Force Deflectin Data \n and curve fit' # pointsize 1.5 --> 受け付けない。 set xlabel 'Deflection, {/Symbol D}_x (m)' set ylabel 'Force, {/Times-Italic F}_A, (kN)' plot 'force.dat' u 1:2 t 'Column data' w p 3,\ '' u 1:3 t 'Beam data' w p 4,\ a1*tanh(x/b1) t 'Column-fit: A=309, B=0.00227',\ a2*tanh(x/b2) t 'Beam-fit: A=260, B=0.00415' (注)w p の後の数値は受け付けなかった。
gnuplot> set term[inal] postscript eps enhanced gnuplot> set output "test.eps" gnuplot> set key left top gnuplot> set size 0.5, 0.5 gnuplot> set xrange [0:4] gnuplot> set yrange [0:4] ------------------- gnuplot> plot 0.2536*x+1.1717 title "lesq fit" w lines linestyle 1,\ "test.dat" u 1:2:3 t "data" w yerrorbars linestyle 2 gnuplot>unset term # windows では set terminal windows gunplot>unset output # windows?では、set outputでよい。なぜか。
-------- latex文書--------------------------------------------------- \documentclass{article} \usepackage[dviout]{graphicx} \begin{document} # \maketitle \begin{figure}[htbp] \begin{center} # \resizebox{120mm}{!}{\includegraphics[scale=0.5]{test.ps}} \includegraphics[width=9cm]{test.ps} \caption{This is a sample figure.} \label{test} \end{center} \end{figure} \end{document}
p 'force.dat' u (3*$2):(sin($3+$1))
set multiplot set size 1,0.5 set origin 0.0,0.5; p sin(x); set origin 0.0,0.0 ; p cos(x) unset multiplot 今までの設定をキャンセルするには? reset ただし、terminalとoutputはデフォルト値に戻されない。
# File name: save.plt - save a Gnuplot plot as a PostScript file # to save the current plot as a postscript file issue the commands: # gnuplot> load 'saveplot' # gnuplot> !mv my-plot.ps another-file.ps set size 1.0, 0.6 set terminal postscript portrait enhanced mono dashed lw 1 "Helvetica" 14 set output "my-plot.ps" replot set terminal x11 set size 1,1 # set terminal postscript {<mode>} {enhanced | noenhanced} # {color | colour | monochrome} # {blacktext | colortext | colourtext} # {solid | dashed} {dashlength | dl <DL>} # {linewidth | lw <LW>} # {<duplexing>} # {"<fontname>"} {<fontsize>} # set terminal gif {transparent} {interlace} # {tiny | small | medium | large | giant} # {size <x>,<y>} # {<color0> <color1> <color2> ...} # set terminal png # {{no}transparent} {{no}interlace} # {tiny | small | medium | large | giant} # {font <face> {<pointsize>}} # {size <x>,<y>} {{no}crop} # {{no}enhanced} # {<color0> <color1> <color2> ...} gnuplot> load 'save.plt' gnuplot> !mv my-plot.ps force.ps gnuplot> !lpr force.ps
-------cat2(executable)------- chmod +x cat2 # cat2: Shell script for putting two Gnuplot plots on one page echo %! > g.ps echo gsave >> g.ps echo 0 400 translate >> g.ps # for Gnuplot plots cat $1 | sed -e "s/showpage//" >> g.ps echo grestore >> g.ps echo gsave >> g.ps echo 0 090 translate >> g.ps # for Gnuplot plots cat $2 >> g.ps lpr -Phudsonlp1 g.ps plot1.ps とplot2.psを1枚に ==> cat2 plot1.ps plot2.ps
p sin(x),cos(x) : 2つの関数をplot
p 'data.dat' w e, 0.25*x+9.0 :エラーバー表示+直線 p '' u 1:($2*$3) : 1:(cos($2)*$3) (cos($1)):((cos($2)*$3) f(x,a,b)=a*x*tanh(b*x) p '' u 1:(f(x, p 'data.dat' w[ith] l[ines] : 線を引く p 'data.dat' t 'データプロット' w p :点でプロット。タイトル p 'data1.dat' t '○○' w p, 'data2.dat' t '××' w lp : 2系列をプロット p 'data.dat' u[sing] 1:2 w lp : 1列目と2列目のデータを使う p [100:300] 'data.dat' : x軸の領域設定 p [100:300] [*:0] 'data.dat' : x軸の領域、y軸の上限を設定。*はautoscale p [-2*pi:2*pi] cos(x) p [] [-2:2] cos(x)
set xr[ange] [aa:bb] set yr[ange] [aa:bb] set grid set xtics 1.1,0.1,1.3 : x軸の目盛りを1.1から1.3まで0.1刻みに set xtics (1.1,"PI/2" pi/2, 1.3) set logscale x(y) : X軸(y軸)をログスケールに set xlabel 'X-Axis' set ylabel 'Y-Axis' set nozreo : x軸とy軸のゼロのところの点線を引かない。 set autoscale x : x軸の範囲を自動に。 show all show title
・pt,pointtype :形(丸、四角) ・ps,pointsize :大きさ ・lt,linetype :カラー、白黒 ・lw,linewidth :太さ
set linestyle 1 lt 1 lw 1.0 set linestyle 2 lt 1 lw 2.0 p 'data.dat' u 1:2 w l linestyle 1,'' u 1:3 t 'graph2' w l 1 linestyles2 set linestyle 1 lt 1 lw 1.0 pt 2 ps 5.0 set linestyle 2 lt 1 lw 2.0 pt 7 ps 1.0
p 'data.dat' smooth csplines (unique,bezier) キュービックスプライン曲線(線形補間という直線、ベジェ曲線)で結ぶ。
w xyerrorbars 想定のデータ構造 X Y dX dY または X Y X1 X2 Y1 Y2 p 'data.dat' u 1:2:3 w yer pt 7 (データのポイント部分を塗りつぶしの丸とする)
全体のタイトルなら set title 各データなら p 'sin.dat' notitle w l
set key bottom グラフの下 set key left 左へ set key left bottom(top) 左下(上) set key 220,0.4 グラフがx軸・y軸座標の単位で(220,0.4)に位置させる
set xlabel 'X-label' set xlabel ラベルを消す
set label '(0,0), center-just.' at -7,0.8 グラフ座標で(-7,0.8)の位置に左寄せで at -7,0.8 center(right) 中央寄せ(右寄せ) set arrow form -7,0.8 to 0,0 lt 2 lw 2 set label 'label' at X,Y font 'Helvetica,24' 文字列のフォントを指定 set nolabel, set noarrow 全体を消す show label, show arrow で番号を確認し、特定のものだけを消すことができる。
set size 2 x軸、y軸を2倍にする set size 1,3 y軸のスケールをx軸の3倍に(縦に拡大) set size square 4 正方形のまま4倍に set size ratio 2 y軸をx軸に対して2倍に拡大 set size ratio -1 x軸とy軸の単位を揃える。地図上でのデータの表示など
set xtics INCR 増分値をINCRに設定 set xtics START, INCR[, END] 目盛りの最初、増分値、(終わり) set xtics ('START' 0, 'MIDDLE' 250, 'END' 500) 目盛りの位置と表示文字の設定
数値表示桁数の設定 set format x "%7.3f" 全体7桁、小数点以下3桁 set xtics (1.1,pi/2,1.3) rep 戻す set xtics
plot 'multi.dat' using ($1-$3) w l p 'multi.dat' u 1:(valid(2) ? $2 : 1/0) 無効なデータを無視する
$0 データ行ごとに増加し、連続空白2行で0にリセット $-1 空行ごとに増加し、連続空白2行で0にリセット $-2 連続空白2行ごとに増加 データ形式に,が使われている場合 p 'ugly.dat' using 1:2 "%l%f*[, ]%lf" はじめの値を1列目、続くカンマもしくはスペースをすべて無視し、次の実数値を2列目とする。 call の場合、$1がパラメータと解釈されるので、colunmn(n)で第n列目を指定する。
print pi # 変数の表示
myfunc(t) = sin(t/T) p [t=-2*pi:2:pi] T=1,myfunc(t) t 'T=1' w l, T=2,myfunc(t) t 'T=2' w l #(関数の実体は定義時ではなく、実行時に評価される)
set samples # 1000 関数プロットの点の数を設定する
splot [-5:5][-5:5] sin(sqrt(x**2+y**2)) set hidden3d 隠線処理 <-> set nohidden3d set contour base 等高線をxy平面に <-> set nocontour set isosamples 30 解像度を30に (default 10)
a~{b} 上付き a_{b} 下付き a`^{b}_{c} 上下に付く {/Symbol G} ギリシャ文字ガンマの大文字 {/Symbol g} ギリシャ文字ガンマの小文字
対数プロットの目盛りを1,10,100から10^0,10^1,10^2のべき乗に変更 set terminal postscript enhanced set logscale y set format y "10^{%L}" set key spacing 1.4 p 'data.dat' u 1:2,t '{/Symbol G}_{a}','' u 1:3 t '{/Symbol r}^{b}' set terminal postscript enchanced 'Times-Roman' 14 #(Helvetica,Times-Roman,Courierなど、defaultはHelvetica 14) set t '{/Times-Roman=40 G} {/Courier=40 G} {/Helvetica=40} {/Symbol=40 G}' set t '{/Times-Roman*2.0 G} {/Courier*2.0 G} {/Helvetica*2.0 G} {/Symbol*2.0 G}' # フォントサイズを2倍に設定 set t '{/Helvetica e}^{- {/Courier i} {/Symbol g}^2}'