2014-03-04 25 views
0

我正在使用java程序在直方图箱之间拆分数组。现在,我想手动标记直方图箱。所以 - 我想转换一些东西,如序列:{-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.5,1,1.5, 2,2.5,4}到下面的图片 -将数组数组转换为直方图箱

enter image description here

有没有办法做到这一点使用什么软件?我在Windows上,基于R,python,java或matlab的一些东西会很棒。我目前使用mspaint手动执行它。

+0

当然,如果你正确地标记你的X轴,并确保酒吧是在正确的地方(即更窄的酒吧更窄的箱子),你不会需要这样的图像?此外,使用图形包,这是疯了。直方图在R:http://www.statmethods.net/graphs/density.html –

回答

0

好,最简单的方法是(蟒蛇):

import matplotlib.pyplot as plt 

d = [-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.5,1,1.5,2,2.5,4] 
hist(d) 

plt.show() 

至于把特殊标签直方图,这是覆盖了一个问题:Matplotlib - label each bin

我猜你要保持它的简单,所以你可以这样做:

import matplotlib.pyplot as plt 

fig, ax = plt.subplots() 
d = [-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.5,1,1.5,2,2.5,4] 
counts, bins, patches = ax.hist(d) 
ax.set_xticks(bins) 

plt.show()