パイプライン gnuplot 出力

パイプライン gnuplot 出力

からインスピレーションを受けるこの問題出力をgnuplotにパイプしてからプロットしてみました。

私のパイプラインは次のとおりです。

cat file.txt |
grep CU | 
perl -e 'while(<>){print +(split)[3], "\n"}' | 
gnuplot file.gp 

ここで、file.gpには次の内容が含まれています。

set terminal dumb
plot '<perl' using 1

パイプの出力は次のとおりです。

-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-77.8333771886
-7.78333787544e+01
-7.78333787544e+01

これで、次のエラーが発生します。

plot '<perl' using 1
               ^
"file.gp", line 3: warning: Skipping data file with no valid points

plot '<perl' using 1
                ^
"file.gp", line 3: x range is invalid

出力をファイルにパイプしてからファイル名を含めるようにgnuplot file.gp変更を実行すると、うまくいきました。file.gp

私がここで何を間違っているのか?

ベストアンサー1

この質問を投稿しようとすると、インターネット接続が失われたため、自分でもう少し試してみて、やっと方法を見つけなければなりませんでした。しかし、今問題について書いたので、新しく発見した知識を共有することをお勧めします。また、より多くの洞察を提供する他の答えをお勧めします。

私の解決策は、file.gp次のように変更することでした。

set terminal dumb
plot '<cat' using 1

次に、パイプチェーンをこのように調整します。

cat file.txt |
grep CU | #I put an identifier in the file 
perl -ne 'print +(split)[3], "\n"' | #strip the identifier
cat | #this makes gnuplot accept the output from the pipe
gnuplot file.gp 

おすすめ記事