Is there a way to return same length arrays in numpy.hist?
问题 I'm trying to create a histogram plot in python, normalizing with some custom values the y-axis values. For this, I was thinking to do it like this: 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') but of course, the last line gives: ValueError: x and y must have same first dimension Is there a way to force np.hist to