〔前の画面〕
〔クリックポイント〕 〔最新の一覧〕
〔全て読んだことにする〕〔全て読んだことにして終了〕 〔終了〕
3038 re(4):データファイルに変数を格納し読み出す方法 |
2015/11/4(水)13:02 - 竹の - takeno.iee.niit.ac.jp - 1206 hit(s)
逆に awk スクリプトから gnuplot を呼ぶ場合はこんな感じです。
BEGIN { pipe = "gnuplot";
print "set term pngcairo" | pipe;
print "set grid" | pipe;
print "set xrange [-1:2]" | pipe;
print "set yrange [-1:5]" | pipe;
}\
/^#/ { if (title == "") title = substr($0, 2);
else if (ptitle == "") {
printf "set output 'test%03d.png'\n", ++N | pipe;
ptitle = substr($0, 2);
printf "set title \"%s\"\n", title | pipe;
printf "plot '-' title '%s' with lp\n", ptitle | pipe }
next }
NF > 0 { print | pipe; next }
title { print "e" | pipe; print "unset output" | pipe;
title = ""; ptitle = "" }
上を test1.awk とすれば「awk -f test1.awk data」で test???.png を
作ります。png じゃなくて画面に表示する場合は、pause とか pipe の
rehash が必要になります。
なお、上では awk 内部からパイプを使っていますが、上の「|pipe」を
全部削除して、「awk -f test1.awk data > test1.gp」として gnuplot スク
リプトを吐き出しておいて、その後「gnuplot test1.gp」とする方法もあり
ます。
# Linux なら、awk スクリプトをシェルスクリプトのヒアドキュメントで書
# けば、一つのシェルスクリプトだけで行うことも可能です
〔ツリー構成〕
┣【3038】 re(4):データファイルに変数を格納し読み出す方法 2015/11/4(水)13:02 竹の (1138) |
〔前の画面〕
〔クリックポイント〕 〔最新の一覧〕
〔全て読んだことにする〕〔全て読んだことにして終了〕 〔終了〕
※ 『クリックポイント』とは一覧上から読み始めた地点を指し、ツリー上の記事を巡回しても、その位置に戻ることができます.