4

gnuplotでは、1つのファイルから複数の曲線/データセットを取得できることがわかりました。

splot "file.dat" using 1:2:3, splot "file.dat" using 1:4:5

また、次のようにスクリプトにデータを埋め込むこともできます。

splot "-" using 1:2:3
 1 0 1
 1 2 3
 0.5 3 1.5

ただし、以下は機能しないようです。

splot "-" using 1:2:3, "-" using 1:4:5
 1 0 1 4 4
 1 2 3 3 4
 0.5 3 1.5 2.5 -1

これは意図的なものですか、回避策はありますか、それとも単に不可能ですか?

4

3 に答える 3

8

Gnuplot 5.0.1 データブロック

main.gnuplot

$data << EOD
 1 0.5  0.25  2  4
 2 1    1     4  8
 3 1.5  2.25  6 12
 4 2    4     8 16
 5 2.5  6.25 10 20
 6 3    9    12 24
 7 3.5 12.25 14 28
 8 4   16    16 32
 9 4.5 20.25 18 36
10 5   25    20 40
11 5.5 30.25 22 44
12 6   36    24 48
EOD

splot \
  "$data" using 1:2:3 with linespoints title "y = x/2, z = y^2", \
  "$data" using 1:4:5 with linespoints title "y = 2x,  z = 2*y"

PNG に変換:

gnuplot -e 'set terminal png' -e 'set output "main.png"' main.gnuplot

出力:

ここに画像の説明を入力

Ubuntu 15.04 にはgnuplot5-x11パッケージがあります。

Ubuntu 14.04 では、ソースから gnuplot を簡単にコンパイルできます。

cvs -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot login
cvs -z3 -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot co -P gnuplot
cd gnuplot
cvs update -r Release_5_0_1
sudo apt-get build-dep gnuplot
sudo apt-get install lua5.2
./prepare
./configure
time make
sudo make install
gnuplot --version

はい、このプロジェクトは執筆時点でCVSを使用しています!

Ubuntu 18.10、gnuplot 5.2 でテスト済み。

于 2015-10-11T11:23:38.143 に答える
6

次のスクリプトは、Gnuplot 4.4 で期待どおりに動作します。以下に出力を添付

set terminal png
set output 'e.png'
splot "-" using 1:2:3, "" using 1:2:3
 1 0 1 4 4
 1 2 3 3 4
 0.5 3 1.5 2.5 -1
e
 1 4 4
 1 3 4
 0.5 2.5 -1
e
set output

splot "-" は 1:2:3 を使用、"" は 1:2:3 を使用

于 2012-05-02T07:14:33.447 に答える
1

回避策は次のとおりです。

splot "-" using 1:2:3
 1 0 1
 1 2 3
 0.5 3

splot "-" using 1:2:3
 1 4 4
 1 3 4
 0.5 2.5 -1

5 列のデータをプロット スクリプトに入れることができる場合は、それを前処理して、プロット スクリプト内の 2 つの 3 列のデータ セットにすることができます。

あなたが試したように、1行で動作させることはできません。できない場合もありますので、

splot 'dat.txt' using 1:2:3, '' using 1:3:4

動作しますが、

splot '-' using 1:2:3, '' using 1:4:5
 1 0 1 4 4
 1 2 3 3 4
 0.5 3 1.5 2.5 -1

ではない。

于 2012-05-02T00:05:20.623 に答える