如何在Matplotlib中的条形组之间添加边距?

时间:2014-11-09 15:49:56

标签: python matplotlib

我已经在另一个线程上查看了解决方案,并没有解决我的问题。这是我的条形图功能:

def bar_chart(self):
            cmap = {1:"red",2:"green",3:"blue",4:"orange",5:"yellow"}
            fig = plt.figure()
            ax = fig.add_subplot(1,1,1)
            res = np.array(self.get_results("classifier_name","custom_report",sort=True))
            names = res[:,0].tolist()
            vals = res[:,1].tolist()
            keys = vals[0].keys()

            N = len(names)
            ind = np.arange(N) 
            width = .2

            rects = []
            breakdown = [[i[key] for i in vals] for key in keys]
            print len(breakdown),len(names)
            for i in range(len(breakdown)):
                rects.append(ax.bar(ind+width*i + width*i, breakdown[i], width, color=cmap[i+1]))

            ax.set_ylabel('Accuracy')
            ax.set_title("Classifier Comparison")
            ax.set_xticks(ind+width)
            ax.set_xticklabels(names)
            ax.tick_params(axis='both', which='major', labelsize=8)

            plt.show()
            return self

这是我的结果: enter image description here

我想在红色和黄色条之间添加边距。有什么想法吗?

0 个答案:

没有答案