gnuplotにプロットする2つの異なるファイルがあります。それらはa)異なるセパレーターb)x軸上の異なる時間を使用します
したがって、それらのそれぞれが別々にプロットするために、私は合格する必要があります
set datafile separator
set timefmt
両方のデータを1つのグラフに追加/オーバーレイして、時間に合わせて調整したいと思います
どうすればこれを行うことができますか?
gnuplotにプロットする2つの異なるファイルがあります。それらはa)異なるセパレーターb)x軸上の異なる時間を使用します
したがって、それらのそれぞれが別々にプロットするために、私は合格する必要があります
set datafile separator
set timefmt
両方のデータを1つのグラフに追加/オーバーレイして、時間に合わせて調整したいと思います
どうすればこれを行うことができますか?
さまざまな区切り記号の問題は、 using 修飾子の後にフォーマットを使用して、ファイルごとに異なる区切り記号を指定することで対処できます。たとえば、次のようになります。
plot 'file1.dat' u 1:2 '%lf,%lf'
コンマ区切りで 2 列のファイルをプロットします。詳細については、help\using を参照してください。
私は時間形式の専門家ではないので、タイムスタンプ形式の問題に対処する方法がわかりません。しかし、多分あなたはのようないくつかの機能を使うことができますstrftime()
。私はそれを試したことはありませんが、必要なことはできるようです。
2つのオプションがあるように私には思えます。1つ目は、データファイル形式を選択し、両方のデータファイルをその形式にすることです。おそらく次を使用しawk
ます。
plot '<awk "-f;" "{print $1,$2}" data1' using 1:2 w lines,\
'data2' using 1:2 w lines
*注: awk コマンドはほぼ確実に異なります。これawk
は、インライン パイプでの使用方法を示しているだけです。
2 番目のオプションはmultiplot
、明示的な軸の配置を使用することです。
set multiplot
set xdata time
set datafile sep ';' #separator for first file
set timefmt "..." #time format for first file
set lmargin at screen 0.9
set rmargin at screen 0.1
set tmargin at screen 0.9
set bmargin at screen 0.1
unset key
plot 'data1' u 1:2 w lines ls 1 nontitle
set key #The second plot command needs to add both "titles" to the legend/key.
set datafile sep ',' #separator for second file
set timefmt "..." #time format for second file
unset border
unset xtics
unset ytics
#unset other stuff that you set to prevent it from being plotted twice.
plot NaN w lines ls 1 title "title-for-plot-1", \
'data1' u 1:2 w lines ls 2 title "title-for-plot-2"
プロットNaN
トリックは、凡例に正しく表示する場合にのみ必要です。凡例を使用していない場合は、心配する必要はありません。
そうです、ファイルごとに 1 回渡す必要がありset datafile separator
ますset timefmt
。次のように実行できます。
set terminal <whatever>
set output <whatever.wht>
set xdata time # tell gnuplot to parse x data as time
set format x '%F' # time format to display on plot x axis
set datafile separator ' ' # separator 1
set timefmt '%F' # time format 1
plot 'file1'
set datafile separator ',' # separator 2
set timefmt '%s' # time format 2
replot 'file2'
replot
コマンド自体は前の行を再プロットします。別の行を指定すると、ここで行ったように最初の行の上に表示されます。
これは私のために働く:
reset
set term pngcairo
set output 'wall.png'
set xlabel "Length (meter)"
set ylabel "error (meter)"
set style line 1 lt 1 linecolor rgb "yellow" lw 10 pt 1
set style line 2 lt 1 linecolor rgb "green" lw 10 pt 1
set style line 3 lt 1 linecolor rgb "blue" lw 10 pt 1
set datafile separator ","
set key
set auto x
set xtics 1, 2, 9
set yrange [2:7]
set grid
set label "(Disabled)" at -.8, 1.8
plot "file1.csv" using 1:2 ls 1 title "one" with lines ,\
"file2.csv" using 1:2 ls 2 title "two" with lines ,\
"file3.csv" using 1:2 ls 3 title "three" with lines
set output