一种解决方案是通过numpy计算直方图并手动绘制条形图:
aa1 = [0,1,1,2,3,3,4,4,5,9]aa2 = [0,1,3,3,4,4,4,4,5,6,7,9]bins = [0,3,9]height = [np.histogram( xs, bins=bins)[0] for xs in [aa1, aa2]]left, n = np.arange(len(bins)-1), len(height)ax = plt.subplot(111)color_cycle = ax._get_lines.color_cyclefor j, h in enumerate(height): ax.bar(left + j / n, h, width=1.0/n, color=next(color_cycle))ax.set_xticks(np.arange(0, len(bins)))ax.set_xticklabels(map(str, bins))



