我想用matplotlib绘制多个横条。 我用过:
a=(45,22,17,28)
b=(32,17,15,27)
c=(15,18,22,25)
rects1 = plt.bar(index, a, bar_width, alpha=opacity, color='b',error_kw=error_config, label='A')
rects2 = plt.bar(index, b, bar_width,alpha=opacity, color='r', error_kw=error_config, label='B',bottom=a)
rects4 = plt.bar(index , c, bar_width, alpha=opacity, color='y', error_kw=error_config, label='C',bottom=a+b)
我想让c超过b超过a,但bottom=a+b不起作用。。。你知道吗
它失败是因为不能添加元组。您需要的是numpy阵列:
这应该是您要查找的配置:
必须用zorder>;a和>;b指定索引c,即(索引c,…,zorder=3);(索引b,…,zorder=2);(索引a,…,zorder=1)。您的代码应该如下所示:
相关问题 更多 >
编程相关推荐