Python でヒストグラム プロットを作成しようとしており、y 軸の値をいくつかのカスタム値で正規化しています。このために、私は次のようにすることを考えていました:
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('foo.bar')
fig = plt.figure()
ax = fig.add_subplot(111)
hist=np.histogram(data, bins=(1.0, 1.5 ,2.0,2.5,3.0))
x=[hist[0]*5,hist[1]]
ax.plot(x[0], x[1], 'o')
もちろん、最後の行は次のようになります。
ValueError: x and y must have same first dimension
np.hist が x[0] 配列と x[1] 配列に同じ数の要素を与えるように強制する方法はありますか?たとえば、そのうちの 1 つの最初または最後の要素を削除しますか?