Bus errorとSegmentation faultに困ったら見るブログ

物理の研究者による日々の研究生活のメモ書きです ( python/emacs/html/Japascript/シェルスクリプト/TeX/Mac/C言語/Linux/git/tmux/R/ポケモンGO)

【matplotlib】1から0に変化する累積分布(cdf)を書く

普通の累積分布はy軸は0から1に向かって増えていく
今回は1から0に向かって減っていく累積分布を書く
あと、縦軸を0~1の範囲に収まるように規格化する必要がある

import matplotlib.pyplot as plt
import numpy as np

val1, base1 = np.histogram(input1, bins=nbins2)
cumulative1 = np.cumsum(val1)/len(input1) # 規格化してるのはここ
weight1 = np.ones(len(input1))/float(len(input1))

fig = plt.figure(figsize=[12, 10])

plt.plot(base1[:-1], 1-cumulative1, c='blue', label="aaaaaa", linewidth = 3.0)

plt.grid()
plt.yscale('log')
plt.xlabel('xxxx')
plt.ylabel('histogram')
plt.title("title")
plt.legend(loc='upper right')
fig.show()
fig.savefig("hoge.png")

ランキング参加中です

↓クリックしていただけると嬉しいです〜