Uncategorized wang.leon on 17 Oct 2006 01:21 am
用Gnuplot进行批处理作图
一个目录里有三十多个一维谱文件,名字分别为S45202.01、S45202.02、S45202.03……把每个文件都画出图形,怎么做?用bash script + gunplot进行批处理可以很快搞定。
第一种方法:建立两个文件,gnuplot脚本文件和bash脚本文件:
plot.plt文件
set term postscript eps enhanced colorset output "S45202.01.eps"set title "Spectrum"set xlabel "Wavelength [{/Symbol l}]"set xtics 5set ylabel "Intension"set ytics 500set gridset nokeyplot "S45202.01" using 1:2 with lines
batch文件
#!/bin/bashsed "s/S45202.01/S45202.02/g" "plot.plt" | gnuplotsed "s/S45202.01/S45202.04/g" "plot.plt" | gnuplot... ...
这里使用了sed命令。更简便的方法是写成
#!/bin/bash for i in S45202.*do sed "s/S45202.01/$i/g" "plot.plt" | gnuplotdone
之后./batch 就可以生成每幅图的eps图像了
更方便的办法是把gnuplot脚本和bash脚本写成一个文件
#!/bin/bashfor i in S45202.*do gnuplot << EOFset term postscript eps enhanced colorset output "$i.eps"set title "Spectrum"set xlabel "Wavelength [{/Symbol l}]"set xtics 5set ylabel "Intension"set ytics 500set gridset nokeyplot "$i" using 1:2 with linesEOFdone