請在gnuplot提示符下執行腳本call
而不是load
。 call
最多可接受10個參數。在gnuplot 5.0之前,這些參數被稱爲$ 0,$ 1,...,$ 9。
在gnuplot的4.6,你的腳本應該是這樣的:
datafile="$0"
outputfile="$0".".pdf"
set xrange [0 to 100]
set xlabel "x-axis"
set ylabel "y-axis"
plot "hello" using 1:($$2*$$2) with lines
set terminal eps
set output outputfile
replot
set terminal wxt
set output
因爲$2
指的是第三個參數的腳本,訪問第二列中使用$$2
代替。或者,您也可以使用1:(column(2)*column(2))
。
你會這樣稱呼它。
gnuplot> call "plot_A.gp" "hello"
這將繪製文件「hello」中的數據並創建一個名爲「hello.pdf」的pdf。作爲最佳做法,我還將終端重置爲wxt
。
從gnuplot 5.0開始,使用$ 0,$ 1等被棄用。相反,您應該使用特殊變量ARG0,ARG2,...,ARG9。我沒有訪問gnuplot 5.0。但我認爲你只需要使用ARG0
而不是$0
。請你可以參考這個答案How to pass command line argument to gnuplot?