2016-09-08 7 views
1

私は現時点でいくつかの粒子追跡を行っています。したがって、私は、通過する粒子の分布と累積関数をプロットしたいと思います。元のx値から補間なしのデータをプロットする

私が分布をプロットすると、プロットは常に1つのタイムステップを早く開始します。 イベントは一種のピークとして、x軸の補間なしでプロットする方法はありますか?

ショート例のデータは...

time = [ 0.,1.,2.,3.,4.,5.,6.,7.,8.,9.] 
counts = [0,0,1,0,2,0,0,0,1,0] 
cum = [ 0.,0.,0.25,0.25,0.75,0.75,0.75,0.75,1.,1.] 

ax1 = plt.subplot2grid((1,2), (0, 0), colspan=1) 
ax1.plot(time, counts, "-", label="Density") 
ax1.set_xlim([0,time[-1]]) 
ax1.legend(loc = "upper left", frameon = False) 
ax1.grid() 

ax2 = plt.subplot2grid((1,2), (0, 1), rowspan=1) 
ax2.step(time, cum, "r",where='post', label="Sum") 
ax2.legend(loc = "upper left", frameon = False) 
ax2.set_ylim([-0.05,1.05]) 
ax2.set_xlim([0,time[-1]]) 
ax2.grid() 

plt.suptitle("Particle distribution \n") 
plt.show() 

enter image description here

任意の助けてくれてありがとうを装着されています!

答えて

1

補間はありません。 plot(.., '-')で、matplotlibは単に"ドットを接続"(あなたが提供するデータ座標)です。線を引いてマーカーを使用しないでください。例:

ax1.plot(time, counts, "o", label="Density") 

bar()は、「ピーク」を描画する:

ax1.bar(time, counts, width=0.001) 

編集bar()年代を描画すると、あなたは、個々の線を描画していないとして、理想的ではないが、非常に小さなバー。 stem()

になり
ax1.stem(time, counts, label="Density") 

:あなたの解決のために

enter image description here

+0

おかげバートそれはmatplotlibが実際にピークを描画する機能を持っていることが判明します! – Sibi

関連する問題