1

これを文書化すると思っただけです(自己回答に従う):

ターミナルで作業する場合gnuplot、キーボードの上下矢印を使用して、入力したコマンドの履歴を反復処理できます - のようにgdb

ただし、頻繁に繰り返す一連のコマンドがある場合があります。これは、単一のコマンドを発行して呼び出したいと思います。たとえば、 のインタラクティブx11ターミナルで作業してgnuplotいて、形式の「スクリーンショット」を取得したいとしpngます。これには、端末を に変更しpng、出力を設定plotし、発行し、端末を に戻す必要がx11あります。また:

set terminal png
set output 'gnuplot.png'
replot
set terminal x11

このシーケンスを単一のコマンドで呼び出したいのですが、セミコロンを区切り文字として使用することで、これらが単一の行に収まることを認識しています。

set terminal png ; set output 'gnuplot.png' ; replot ; set terminal x11

には、ユーザ定義コマンドを許可するgdbコマンドdefineがあります。端末で発行するだけです。gdb

(gdb) define fn
> finish
> next
> end

...そしてその時点から、その端末に入力して一連のandfnを呼び出すことができます。finishend

に似たようなものはありgnuplotますか?

4

1 に答える 1

1

help macrosはい、あるようです - マクロ ( in )と呼ばれる機能があり、名前の前に ("at" 文字) をgnuplot追加することで文字列変数を展開できます。@

この機能はデフォルトで無効になっているため、有効にすることを検討する必要があります。そのシーケンスを init スクリプト ファイルに保存するのが最適な理由は次のinit.gpとおりです。

print ""
print "init.gp starting"

set terminal x11

# define capt string variable as sequence
# of commands, semicolon separated

capt = "print 'Saving...' ; set terminal png ; set output 'gnuplot.png' ; replot ; set terminal x11"

print "macros state: "
show macros

print "enabling macros state:"
set macros
show macros

print "The @capt command should be available now."
print ""
print "init.gp ending"
print ""

次に、次のような端末セッションを実行できますgnuplot

$ gnuplot

    G N U P L O T
    [...]

Terminal type set to 'wxt'

gnuplot> load "init.gp"

init.gp starting
macros state: 

    command line macros will not be expanded

enabling macros state:

    command line macros will be expanded

The @capt command should be available now.

init.gp ending

gnuplot> plot sin(x)

gnuplot> @capt
Saving...
Terminal type set to 'png'
Options are 'nocrop font /usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf 12 size 640,480 '
Terminal type set to 'x11'
Options are ' nopersist'

gnuplot> plot cos(x)
Closing gnuplot.png

gnuplot> exit

$ identify gnuplot.png 
gnuplot.png PNG 640x480 640x480+0+0 8-bit PseudoClass 102c 5.58KB 0.000u 0:00.000

さて、これが誰かに役立つことを願っています、
乾杯!

于 2013-01-23T05:20:58.537 に答える