У меня есть набор данных в моем текстовом файле.Я не уверен, как мне следует учитывать значения моего бина, чтобы построить гистограмму с помощью matplotlib в python.Более того, я получаю странного короля величин.
import matplotlib.pyplot as plt
import numpy as np
import matplotlib
f= np.loadtxt('load.txt', delimiter=',', unpack= True)
# set bins' interval for your data
# You have following intervals:
# 1st col is number of data elements in [0,10000);
# 2nd col is number of data elements in [10000, 20000);
# ...
# last col is number of data elements in [100000, 200000];
#bins = [0,10000,20000,50000,100000,200000]
bins = [0,50,100,150,200]
plt.hist(f, histtype = 'bar', bins = bins)
plt.xlabel('x values')
plt.ylabel('y values')
plt.title('Random plot')
#plt.legend()
plt.show()
data:
1,100
2,10
3,50
4,110
5,120
6,200