2013-06-21 31 views
11

所有matplotlib exampleshist()生成一个数据集,自动提供数据设置到hist功能与一些二进制位(可能非均匀地间隔开)和功能计算并绘制直方图。直方图这是已经装仓,我有仓和频率值

我已经有直方图数据,我只是想绘制它,我该怎么做?!例如,我有垃圾箱(半开放范围由广场和弯曲托架符号表示),

[0, 1) 0 
[1, 2) 3 
[2, 3) 8 
[3, 4) 6 
[4, 5) 2 
[5, 6) 3 
[6, 7) 1 
[7, 8) 0 
+1

你想'酒吧'http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.bar – tacaswell

回答

7

或许重量参数将是你的问题的帮助。

import matplotlib.pyplot as plt 

a= [1,2,3,4,5,6,7,8,9] 
b= [5,3,4,5,3,2,1,2,3] 
plt.hist(a,9, weights=b) 
plt.show() 

或者,正如tcaswell所说,您可以创建一个条形图并更改x轴。

Using matplotlib how could I plot a histogram with given data in python

是一个链接。

+0

我做了一个编辑。该代码为我工作。 –

+0

感谢您的帮助。 –