1

次のコマンドでヒストグラムをプロットしています。

n=3
max=0.5
min=-2.5
width=(max-min)/n
hist(x,width)=width*floor(x/width)+width/2.0
plot "< awk '{if (\$1<3.9 && \$1>3.8) {print \$0}}' /path_to_file/" u (hist(\$2,width)):(1.0) smooth freq w boxes lc rgb "black" lt 1 lw 0.5 notitle

これは私にこれを取得します:

ヒストグラム

どうやら、私はデータファイルに基づいて推測しているgnuplotようで、 [0.5:- 0.5:-1.5]

間隔 [0.5:-0.5]-[-0.5:-1.5]-[-1.5:-2.5] を使用するには、これらのビンが必要です。これにより、ビンは [0.0:-1.0:-2.0] の中心になります。

どうすればこれを達成できますか?

4

2 に答える 2

0

あなたが望む

hist(x,width)     = width*(floor(x/width+0.5))

これは以前の回答と同等ですが、簡略化されたバージョンですhttps://stackoverflow.com/a/13896530/834416

hist(x,width)     = width*floor((x + width/2)/width)

同じ問題があり、 https://stackoverflow.com/a/24923363/834416に回答とサンプル コードと出力を投稿しました。

于 2014-07-24T03:08:23.230 に答える
0

ヒストグラムの間隔は、関数によって決定されますhisthist関数は数値の範囲を単一の値に縮小するため、gnuplot は関数によって返された値を中心に棒グラフをプロットできますhist

元の投稿では、hist(x,width)=width*floor(x/width)+width/2. したがって、 と が得られhist(x,width)=0.5ます。最終的に、 を中心とした棒グラフが得られます。width=10 <= x < 10.5

ここで、間隔を [-0.5:0.5]、[-0.5:-1.5] などに設定する場合は、関数を変更してwhenおよび をhist返すようにすることができます。0.0width=1-0.5 <= x < 0.5

width=1
hist(x,width)=width*floor((x + width/2)/width)
plot "< awk '{if (\$1<3.9 && \$1>3.8) {print \$0}}' /path_to_file/" u (hist(\$2,width)):(1.0) smooth freq w boxes lc rgb "black" lt 1 lw 0.5 notitleenter code here
于 2012-12-15T21:47:25.883 に答える