Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.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
matplot python直方图中缺少最后一个箱子_Python_Matplotlib - Fatal编程技术网

matplot python直方图中缺少最后一个箱子

matplot python直方图中缺少最后一个箱子,python,matplotlib,Python,Matplotlib,我正试图根据我的价值来绘制历史记录 x = ['3', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5', '2', '3', '4', '5', '6', '4', '2', '0', '1', '9', '8', '8', '8', '8', '8', '9', '3', '8', '0', '9', '5', '2', '5', '7', '2', '0', '1', '0', '6', '5'] x_num

我正试图根据我的价值来绘制历史记录

x = ['3', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5',
     '2', '3', '4', '5', '6', '4', '2', '0', '1', '9', '8', 
     '8', '8', '8', '8', '9', '3', '8', '0', '9', '5', '2',
     '5', '7', '2', '0', '1', '0', '6', '5']
x_num = [int(i) for i in x]

key = '0123456789'
for i in key:
    print(i," count =>",x.count(i))

plt.hist(x_num, bins=[0,1,2,3,4,5,6,7,8,9])

最后两个数字“8,9”存储箱的分发计数应为6,4 但在直方图中,它将8和9结合起来,得到10的值,而不是将它们分开。垃圾箱的总数应该是10=>但它只给出了9的图表

我怎样才能把它们分开,打破8和9

plt.hist(x_num,箱子=[0,1,2,3,4,5,6,7,8,9,10])
来自文档:
箱子的边缘。长度nbins+1(nbins最后一个箱子的左边缘和右边缘)
import matplotlib.pyplot as plt


x = ['3', '1', '4', '1', '5', '9', '2', '6', '5', '3', '5',
     '2', '3', '4', '5', '6', '4', '2', '0', '1', '9', '8',
     '8', '8', '8', '8', '9', '3', '8', '0', '9', '5', '2',
     '5', '7', '2', '0', '1', '0', '6', '5']
x_num = [int(i) for i in x]

key = '0123456789'
for i in key:
    print(i, " count =>", x.count(i))

plt.hist(x_num, bins=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10])
plt.show()