2017-07-19 8 views
1

2つの未加工データの列(xとyの変位)を持つファイルがあります。ファイルの各行は、新しいタイムステップに対応します。 xとyの変位を相互に関連づけたいと思います。未処理のデータからgnuplotの2Dヒストグラム(ヒートマップ)を作成します

各行について、x値をビンし、y値をヒストグラムにビンして、対応する(x、y)ビンに「カウント」を加えたいと思います。

私はすでにこれを行うコードを持っていますが、それは各軸をビンして、対応するスペースにポイント/ 'カウント'を配置しますが、問題は 'カウント'を加算しないということです。代わりに、ポイントはお互いに重なり合うだけです。お互いに重なり合う複数の点がある場合、点のいくつかが他の点よりも大きく/暗く見えることがあります。これと同じように:

Gnuplot output with my full data set. Shows the bolder overlapping points

私の質問は:どのように私は(私のイメージのように)互いの上に配置されているポイント/「カウント」、取得することができ、私はできるように、代わりに一緒に追加します相関の高い領域がカラーマップなどのどこにあるのか確認してください。

I'd like my plot to look like this instead, with the color value corresponding to the number of points/'counts' in the 2D bin

ちょっと私はそれが何をしたいのかない私はgnuplotコード:

#!/usr/local/bin/gnuplot 

set term postscript eps enhanced color 
set encoding utf8 
set offsets 
set style fill solid 

bin(x,width,min)=width*(floor((abs(x) - min)/width) + 0.5) + min 

set output '2d.test.eps' 
set palette defined (-1 "red", 0 "white", 1 "blue") 
set cbrange [0:10] 

binwidth=0.1 
binwidth=0.1 
xmin=-360 
ymin=-360 
set boxwidth binwidth*0.75 

set view map 
splot '2d.dat' using (bin($1,binwidth,xmin)):(bin($2,binwidth,ymin)):(1.0) not 

データファイル形式:

0.864 3.868 
    1.878 3.617 
    0.138 2.787 
    0.646 3.220 
    -0.969 3.176 
    -0.447 3.031 
    -0.316 3.130 
    0.205 3.342 
    -1.127 3.661 
    -1.349 3.702 
... 

答えて

0

あなたはawkので計算を行うために喜んでいる場合あなたはuniqを使用してカウントすることができます:

awk 'function abs(x){return (sqrt(x*x))}{print 0.1*(int((abs($1)+360)/0.1)+0.5)-360" "0.1*(int((abs($2)+360)/0.1)+0.5)-360}' input.dat | sort | uniq -c > output.dat 

UNIQは

set view map 
splot "output.dat" 2:3:1 matrix with image 

ようにあなたはこれをプロットする必要がある回数を付加しますので、これはまた、gnuplotの内から直接可能でなければなりません:

splot "<awk 'function abs(x){return (sqrt(x*x))}{print 0.1*(int((abs($1)+360)/0.1)+0.5)-360\" \"0.1*(int((abs($2)+360)/0.1)+0.5)-360}' data.dat | sort | uniq -c" u 2:3:1 2:3:1 matrix with image 

(エスケープ "文字に注意してください!)

関連する問題