Archive for the ‘@linux’ Category

gnuplot, briefly II plot

October 14, 2006

gnuplot最重要的当然是作图拉.:) 譬如experimental data存在”calibration.dat”里:

calibration.datthe1st, 4th, 2nd,5th columns分别是dL , L, dL的实验误差, L的实验误差. 把L作为x, dL作为y来plot, 并且带上两者的实验误差, 用命令: plot “calibration.dat” usi 4:1:5:2 w xyerr title “L v.s dL” , 其中”usi 4:1:5:2″代表用第四,一,二,五列的数据. (默认x,y,xerr,yerr) “w xyerr”表示用xyerror bar, “title …”用来作legend.

plot

若打算一次作多种图比如在上面的例子里再作gaussian函数图像, 就用,\来分隔 :

plot “calibration.dat” usi 4:1:5:2 w xyerr title “L vs dL” ,\

300*exp(-0.01*(x-200)**2) title “gaussian distribution”

vplot

当然, 可以把所需要作的流程, 如set term, plot “file”之类写在一个文件里面,如plot.那么直接在linux下输入gnuplot plot就行了. !!

谈谈著名的gnuplot:), briefly I 设置

October 14, 2006

大概是linux下最著名的画图程序了. The most important: it’s free. 最新的版本是4.0.

Fortran下面调用gnuplot使用call system”gnuplot filename” 即可; C下, 网上free code下载.
现谈谈设置.gnuplot所有设置都应在作图之前进行, 包括设置输出文件名. 在command line下键入gnuplot,进入程序:

gnuplot

4.0大概提供60多种图形文件输出形式(terminal type), 包括.gif, .png, .jpeg 以及.ps. 键入set term 会显示所安装的版本提供的所有文件格式(press “q”键退出显示). 用set term <filetype>来设置输出文件形式. :

set term

然后用set output “filename” 选择输出文件名.

结束对文件格式的操作, 然后就进行图形的设置, 一般常用有set xrange[xmin:xmax], set xtics <#>(divide x interval with increment #), set mxtics <#> (draw small tics inside the interval), set xlabels “xlabel” (insert x name)以及对应的y轴操作.接着还有set grid(画网格)等等.全部的set命令可以用help set来查看:

set pic