Python 直方图箱大小
我有一个这样的代码,我想知道为什么我的两个绘制图的箱子大小是不同的Python 直方图箱大小,python,pandas,histogram,Python,Pandas,Histogram,我有一个这样的代码,我想知道为什么我的两个绘制图的箱子大小是不同的 import matplotlib.pyplot as pyplot bins=15 pyplot.rcParams["figure.figsize"] = (10,10) #echte_Ladezeit pyplot.hist(Y_test, bins, alpha=1, label='Y_test; orange Dateien', color='orange', weights = np.ones_like(Y_tes
import matplotlib.pyplot as pyplot
bins=15
pyplot.rcParams["figure.figsize"] = (10,10)
#echte_Ladezeit
pyplot.hist(Y_test, bins, alpha=1, label='Y_test; orange Dateien',
color='orange', weights = np.ones_like(Y_test)/float(len(Y_test)))
pyplot.hist(Y_train, bins, alpha=1, label='Y_train; grüne Dateien',
color='green', weights = np.ones_like(Y_train)/float(len(Y_train)))
pyplot.title('Verteilung echte_Ladezeit')
pyplot.xlabel('echte_Ladezeit')
pyplot.ylabel('Häufigkeit [%]')
pyplot.legend(loc='upper right')
pyplot.show()
实际上,橙色和绿色的标记宽度应该是相同的,对吗?我的代码有错误吗?
您的代码包含
pyplot.hist(…,bins,…)
其中bins=15
。这意味着15个箱子在最大值和最小值之间等距排列。两个数据集的“最大”和“最小”值不同,因此您可以得到不同的15个存储箱集。如果您想为每个数据集获取宽度相等的容器,那么您至少有两个选项
列表(范围(0,40000+1,5000))
)您的代码包含
pyplot.hist(…,bin…)
其中bin=15
。这意味着15个箱子在最大值和最小值之间等距排列。两个数据集的“最大”和“最小”值不同,因此您可以得到不同的15个存储箱集。如果您想为每个数据集获取宽度相等的容器,那么您至少有两个选项
列表(范围(0,40000+1,5000))
)