Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 直方图箱大小_Python_Pandas_Histogram - Fatal编程技术网

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))